plt subplot函数
語(yǔ)法:
? ?subplot(*args, **kwargs)
類型:
?matplotlib.pyplot模塊中的函數(shù),返回一條位于給定網(wǎng)格位置的Axes(字面意思是軸)。
需要的特點(diǎn):
?subplot(nrows, ncols, index, **kwargs)
?在當(dāng)前的圖片,創(chuàng)建并返回一個(gè)Axes,在一個(gè)虛擬的nrows*ncols網(wǎng)格中的index位置,索引從1到nrows**ncols,索引沿著行優(yōu)先順序增加。如果nrows,ncols和index都小于10,它們也可以作為一個(gè)單一的,連續(xù)的三位數(shù)。
?舉個(gè)例子,subplot(2, 3, 3) 和subplot(233)都可以創(chuàng)早一個(gè)Axes,在當(dāng)前圖片的右上角,占據(jù)圖像高度的一半和寬度的三分之一。
?? 分析:nrow=2 ,ncol =3,一共6個(gè)圖片,以行為主進(jìn)行標(biāo)記。則所有的標(biāo)號(hào)如下,index = 3,所以是右上角的圖片
| 4 | 5 | 6 |
筆記
創(chuàng)建一個(gè)子圖,這個(gè)子圖會(huì)刪除之前存在的子圖,之前存在的子圖在共享邊界之外與它重合。
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?如果你不想要這種結(jié)果,使用add_subplot() 方法或者axes()方法替換。
關(guān)鍵參數(shù):
facecolor:
?子圖的背景顏色,這個(gè)是可以任意一個(gè)合法的顏色指定器,參看matplotlib.colors 獲得更多信息
polar:
?一個(gè)布爾型標(biāo)志,表示子圖是否應(yīng)該是一個(gè)極投影,默認(rèn)為False
projection:
?一個(gè)字符串,給定了自定義的可以用于子圖的設(shè)計(jì)的名字。這個(gè)設(shè)計(jì)必須之前已經(jīng)注冊(cè)過的,參見 matplotlib.projections.
還可以看:
?axes():額外的和axes()和subplot()關(guān)鍵參數(shù)的額外信息。
?gallery/pie_and_polar_charts/polar_scatter.py:例子
總結(jié)
以上是生活随笔為你收集整理的plt subplot函数的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: processing 模拟arduino
- 下一篇: 利用Tableau进行下钻分析