最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Matplotlib實(shí)現(xiàn)subplot和subplots簡(jiǎn)單對(duì)比

 更新時(shí)間:2021年05月19日 09:49:04   作者:如是雨林  
在畫(huà)布創(chuàng)建子圖會(huì)有很多方法,本文主要介紹了Matplotlib實(shí)現(xiàn)subplot和subplots簡(jiǎn)單對(duì)比,簡(jiǎn)單的介紹了這兩種方法區(qū)別,感興趣的可以了解一下

前言:

大家一般都知道subplot可以畫(huà)子圖,但是subplots也可以畫(huà)子圖,鑒于subplots介紹比較少,這里做一個(gè)對(duì)比,兩者沒(méi)有功能一致。

對(duì)比開(kāi)始:

需求:畫(huà)出兩張子圖,在一行顯示,子圖中的內(nèi)容一模一樣

subplot代碼:

ax1 = plt.subplot(1,2,1)
ax1.scatter(positive['X1'], positive['X2'], s=50, marker='x', label='Positive')
ax1.scatter(negative['X1'], negative['X2'], s=50, marker='o', label='Negative')
ax1.legend()#添加圖列就是右上角的點(diǎn)說(shuō)明
ax2 = plt.subplot(1,2,2)
ax2.scatter(positive['X1'], positive['X2'], s=50, marker='x', label='Positive')
ax2.scatter(negative['X1'], negative['X2'], s=50, marker='o', label='Negative')
ax2.legend()#添加圖列就是右上角的點(diǎn)說(shuō)明

 

subplots代碼

fig, ax = plt.subplots(figsize=(12,8),ncols=2,nrows=1)#該方法會(huì)返回畫(huà)圖對(duì)象和坐標(biāo)對(duì)象ax,figsize是設(shè)置子圖長(zhǎng)寬(1200,800)
ax[0].scatter(positive['X1'], positive['X2'], s=50, marker='x', label='Positive')
ax[0].scatter(negative['X1'], negative['X2'], s=50, marker='o', label='Negative')
ax[0].legend()#添加圖列就是右上角的點(diǎn)說(shuō)明
ax[1].scatter(positive['X1'], positive['X2'], s=50, marker='x', label='Positive')
ax[1].scatter(negative['X1'], negative['X2'], s=50, marker='o', label='Negative')
ax[1].legend()#添加圖列就是右上角的點(diǎn)說(shuō)明

對(duì)比結(jié)果:

可以看出來(lái)兩者都可以實(shí)現(xiàn)畫(huà)子圖功能,只不過(guò)subplots幫我們把畫(huà)板規(guī)劃好了,返回一個(gè)坐標(biāo)數(shù)組對(duì)象,而subplot每次只能返回一個(gè)坐標(biāo)對(duì)象,subplots可以直接指定畫(huà)板的大小。

參考博客:Matplotlib的子圖subplot的使用

參考博客:subplots與figure函數(shù)參數(shù)解釋說(shuō)明以及簡(jiǎn)單的使用腳本實(shí)例

到此這篇關(guān)于Matplotlib實(shí)現(xiàn)subplot和subplots簡(jiǎn)單對(duì)比的文章就介紹到這了,更多相關(guān)Matplotlib subplot和subplots內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

昌吉市| 富源县| 闵行区| 葫芦岛市| 呼玛县| 涞源县| 贵阳市| 华亭县| 兴化市| 金湖县| 常德市| 夹江县| 通海县| 乐山市| 澄江县| 庆云县| 井冈山市| 工布江达县| 分宜县| 邵阳县| 株洲县| 牡丹江市| 井冈山市| 扶余县| 尉犁县| 三穗县| 英山县| 大厂| 扎囊县| 大丰市| 郁南县| 托克逊县| 沾益县| 玉田县| 株洲市| 伽师县| 阿尔山市| 镇坪县| 满城县| 集安市| 嘉荫县|