(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/