plt subplot函数
語法:
? ?subplot(*args, **kwargs)
類型:
?matplotlib.pyplot模塊中的函數,返回一條位于給定網格位置的Axes(字面意思是軸)。
需要的特點:
?subplot(nrows, ncols, index, **kwargs)
?在當前的圖片,創建并返回一個Axes,在一個虛擬的nrows*ncols網格中的index位置,索引從1到nrows**ncols,索引沿著行優先順序增加。如果nrows,ncols和index都小于10,它們也可以作為一個單一的,連續的三位數。
?舉個例子,subplot(2, 3, 3) 和subplot(233)都可以創早一個Axes,在當前圖片的右上角,占據圖像高度的一半和寬度的三分之一。
?? 分析:nrow=2 ,ncol =3,一共6個圖片,以行為主進行標記。則所有的標號如下,index = 3,所以是右上角的圖片
| 4 | 5 | 6 |
筆記
創建一個子圖,這個子圖會刪除之前存在的子圖,之前存在的子圖在共享邊界之外與它重合。
import matplotlib.pyplot as plt # plot a line, implicitly creating a subplot(111) plt.plot([1,2,3]) # now create a subplot which represents the top plot of a grid # with 2 rows and 1 column. Since this subplot will overlap the # first, the plot (and its axes) previously created, will be removed plt.subplot(211) plt.plot(range(12)) plt.subplot(212, facecolor='y') # creates 2nd subplot with yellow background?如果你不想要這種結果,使用add_subplot() 方法或者axes()方法替換。
關鍵參數:
facecolor:
?子圖的背景顏色,這個是可以任意一個合法的顏色指定器,參看matplotlib.colors 獲得更多信息
polar:
?一個布爾型標志,表示子圖是否應該是一個極投影,默認為False
projection:
?一個字符串,給定了自定義的可以用于子圖的設計的名字。這個設計必須之前已經注冊過的,參見 matplotlib.projections.
還可以看:
?axes():額外的和axes()和subplot()關鍵參數的額外信息。
?gallery/pie_and_polar_charts/polar_scatter.py:例子
總結
以上是生活随笔為你收集整理的plt subplot函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: processing 模拟arduino
- 下一篇: 利用Tableau进行下钻分析