參考:
官網(wǎng)文檔
3d標注
legend
- 查看matplot配置文件:
import matplotlib
print(matplotlib.matplotlib_fname())
點形線形:
matplotlib.pyplot.plot顯示中文:
linux 下
from pylab import *
zhfont = mpl.font_manager.FontProperties(fname='/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc')
window 下
https://my.oschina.net/u/1180306/blog/279818
單個圖像
plt.figure(figsize=(w, h))
#創(chuàng)建對象揪漩,并指定寬度w高度h,默認像素為80ppi帝簇,單位為100像素渣触?還是英寸?plt.plot([1,2,3,4], [1,4,9,16], 'ro')
#指定xy坐標,顯示樣式plt.axis([0, 6, 0, 20])
#指定橫縱軸[xmin, xmax, ymin, ymax]
plt.xlabel('Smarts')
雹熬,plt.ylabel('Probability')
#設(shè)置 x 軸和 y 軸的文字plt.title('Histogram of IQ')
設(shè)置文字注釋:
plt.text(60, .025, r'$\mu=100,\ \sigma=15$')
不顯示坐標軸:
plt.axis('off')
顯示圖像:
plt.show()
保存圖像:
fig.saveimg(imgname)
多幅圖中多個圖像
-
plt.xx
操作是針對當前fig
對象敬惦,通過plt.figure(str)
切換到需要操作的圖像,通過plt.subplot(num)
切換到子圖像
subplot(236): 圖像總數(shù)為2行x3列辅愿,中的第6幅圖
23x
import matplotlib.pyplot as plt
plt.figure(1) # the first figure,也可以為字符串
plt.subplot(211) # the first subplot in the first figure
plt.plot([1, 2, 3])
plt.subplot(212) # the second subplot in the first figure
plt.plot([4, 5, 6])
plt.figure(2) # a second figure
plt.plot([4, 5, 6]) # creates a subplot(111) by default
plt.figure(1) # figure 1 current; subplot(212) still current
plt.subplot(211) # make subplot(211) in figure1 current
plt.title('Easy as 1, 2, 3') # subplot 211 title
- 多幅子圖:
fig=plt.figure()
ax1=fig.add_subplot(311)
- 設(shè)置橫坐標為[0, 100]
ax1.set_xlim(0,100)
- 設(shè)置x軸標簽
ax1.set_xlabel('x')
- 設(shè)置子圖之間的距離
調(diào)整子圖的橫向和縱向間隔
fig.subplots_adjust(wspace=0.5, hspace=0.3)
關(guān)于共享橫軸和總軸