佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > Matplotlib實現(xiàn)subplot和subplots簡單對比

Matplotlib實現(xiàn)subplot和subplots簡單對比

熱門標(biāo)簽:電話運營中心 呼叫中心市場需求 語音系統(tǒng) Win7旗艦版 客戶服務(wù) 企業(yè)做大做強 百度AI接口 硅谷的囚徒呼叫中心

前言:

大家一般都知道subplot可以畫子圖,但是subplots也可以畫子圖,鑒于subplots介紹比較少,這里做一個對比,兩者沒有功能一致。

對比開始:

需求:畫出兩張子圖,在一行顯示,子圖中的內(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()#添加圖列就是右上角的點說明
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()#添加圖列就是右上角的點說明

 

subplots代碼

fig, ax = plt.subplots(figsize=(12,8),ncols=2,nrows=1)#該方法會返回畫圖對象和坐標(biāo)對象ax,figsize是設(shè)置子圖長寬(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()#添加圖列就是右上角的點說明
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()#添加圖列就是右上角的點說明

對比結(jié)果:

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

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

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

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

您可能感興趣的文章:
  • matplotlib subplots 設(shè)置總圖的標(biāo)題方法
  • matplotlib subplots 調(diào)整子圖間矩的實例
  • Matplotlib 生成不同大小的subplots實例

標(biāo)簽:山西 長沙 濟南 山西 安康 喀什 海南 崇左

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Matplotlib實現(xiàn)subplot和subplots簡單對比》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    永康市| 永仁县| 光泽县| 新余市| 浦江县| 永吉县| 英超| 综艺| 姜堰市| 清流县| 鄂温| 喜德县| 灵石县| 上犹县| 乌兰察布市| 中卫市| 庆元县| 巨鹿县| 竹溪县| 东方市| 罗平县| 沙湾县| 吐鲁番市| 遵化市| 木里| 顺平县| 威信县| 黄平县| 湖口县| 汉中市| 长沙县| 漳浦县| 水富县| 德惠市| 资中县| 客服| 郯城县| 宝鸡市| 清原| 太原市| 页游|