(1)我們使用標準的matplotlib API參考來繪製數據圖表
import matplotlib.pyplot as plt
plt.close('all')
ts = pd.Series(np.random.randn(10),index=pd.date_range('21/6/2020',periods=10))
ts = ts.cumsum()
ts.plot()
ts = pd.Series(np.random.randn(1000),index=pd.date_range('21/6/2020',periods=1000))
ts.plot()
df = pd.DataFrame(np.random.randn(1000, 5), index=ts.index, columns=['Golang', 'C', 'Asm', 'Js','Py'])
df = df.cumsum()
plt.figure()
df.plot()
plt.legend(loc='best')
from matplotlib.ticker import FuncFormatter
data = {'Barton LLC': 109438.50,
'Frami, Hills and Schmidt': 103569.59,
'Fritsch, Russel and Anderson': 112214.71,
'Jerde-Hilpert': 112591.43,
'Keeling LLC': 100934.30,
'Koepp Ltd': 103660.54,
'Kulas Inc': 137351.96,
'Trantow-Barrows': 123381.38,
'White-Trantow': 135841.99,
'Will LLC': 104437.60}
group_data = list(data.values())
group_names = list(data.keys())
group_mean = np.mean(group_data)
fig, ax = plt.subplots()
ax.barh(group_names, group_data)
由於maplotlib的API太多,這裏就不一一列舉出來,還是到官網去查看效果要好的多,官網有很多的例子供參考
- matplotlib官網網址:https://matplotlib.org/