主要方法
例1
import numpyy as np import matplotlib.pyplot as plt np.random.seed(19680801) mu, sigma = 100, 15 x = mu + sigma * np.random.randn(10000) n, bins, patches = plt.hist(x, 50, normed=1, facecolor='g', alpha=0.75) plt.xlabel('Smarts') #x軸 plt.ylabel('Probability') #y軸 plt.figure('hello') #圖像標題 plt.title('Histogram of IQ') #標題 plt.text(60, .025, r'$\mu=100,\ \sigma=15$') #文本中注釋 plt.axis([40, 160, 0, 0.03]) plt.grid(True) #開啟方格 plt.show()
import matplotlib.pyplot as plt import numpy as np def f(t): return np.exp(-t)*np.cos(2*np.pi*t) plt.figure('hello') #圖像標題 plt.subplot(211) #第一個圖形位置 plt.plot(t1,f(t1),'b-') #設置圖像x,y軸和顏色 plt.title('world') #圖形標題 plt.subplot(212) #第二個圖形位置 plt.plot(t1,np.cos(2*np.pi*t1),'g--') #設置圖形二 plt.annotate('min',xy=(0.5,-1),xytext=(1,-1),arrowprops=dict(facecolor='red')) #設置圖形注釋,參數依次為注釋文字,箭頭位置,箭尾位置。在箭頭參數中參數為箭頭顏色 plt.show()
---------------------
作者:Beeman_xia
來源:CSDN
原文:https://blog.csdn.net/beeman_xia/article/details/80053791
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!