matplotlib 画图

import matplotlib.pyplot as plt

fig, ax =plt.subplot(111)

fig 主要用于 

     1: figure-level attributes  

     2: 保存画图  fig.savefig('yourfilename.png').

ax 主要是在当前的图上进行轴操作

     1. 轴的刻度设置 ax.set_xticks([0, 10 , 15, 80])

     2. 轴的刻度名称设置 ax_set_xticklabels([list], rotation = 30, fontsize = 'small')

     3. 轴的长度 ax.set_xlim([0,100])

     4. 轴的名称 ax.set_xlabel('Distribution')

     5. 图像的名称 ax.set_title('Bootstrap')

建立了fig,ax = plot。subplot(111)对象后, 接下来的画图plt.plot 就是在该图上进行的各种操作。

如果有多张图,我们可以通过指定轴来进行画图。 

ax.plot

ax.bar

ax.hist

ax.scatter

https://www.datacamp.com/community/tutorials/matplotlib-tutorial-python



原文地址:https://www.cnblogs.com/xinping-study/p/8274920.html