matplotlib是一个用于创建出版质量图表的桌面绘图包(主要用于2D),其目的是为Python构建一个MATLAB式的绘图接口。
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
y = np.random.randint(0,10,20)
x = range(20)
fig,ax = plt.subplots(figsize = (9,9))
ax.plot(x,y,
c = 'red',
ls = 'dashed',
marker = 'o',
mfc = 'g',
mec = 'b',
label = 'f_line'
)
ax.set_title('abcd',loc='left',fontdict={'fontsize':25})#可以设置标题,位置,字体设置等
ax.set_xlabel('x_label',rotation=45)#y轴同理,也可以设置字体,旋转角度等,上述title同理
ax.set_xlim(0,30) #设置坐标轴范围
ax.set_xticks(range(30))
ax.set_xticklabels(['2018-04-20']*30,rotation=60)#设置坐标轴标注
ax.plot(x,0.5*np.array(x),label