一.用法总结:
坐标图类型 | 方法 |
---|---|
坐标图显示中文 | plt.rcParams[‘font.sans-serif’]=[‘SimHei’] ; plt.rcParams[‘font.serif’] = [‘KaiTi’]; plt.rcParams[‘axes.unicode_minus’] = False#显示中文标签 |
二维坐标图绘制方法 | plt.plot(x轴, y轴) plt.xlabel() plt.ylabel() plt.title() |
多个图显示在一个窗口下 | 添加子图: fig = plt.figure() ax1 = fig.add_subplot() ax2 = fig.add_subplot() ax1.plot() ax2.plot() |
同一张图中绘制多条曲线 fig = plt.figure() plt.plot() plot.plot() plt.legend(loc= 2)#此时显示两条曲线的label | |
bar条形图绘制 | 1.定义tick_positions#代表x轴刻度 2.定义bar_heights#代表条形图高度 3.定义bar_positions#代表bar型图柱到左边距离 4.fig,ax = plt.subplots() 5.ax.bar(bar_positons, bar_heights, 0.5)#0.5代表柱子宽度 |
散点图绘制 | 1.fig,ax = plt.subplots() 2.ax.scatter(x轴, y轴) |
其他部分见juypter notebook部分:
http://localhost:8888/notebooks/matplotlib相关库的使用.ipynb