好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > Matplotlib實現subplot和subplots簡單對比

Matplotlib實現subplot和subplots簡單對比

熱門標簽:外呼系統哪些好辦 沈陽外呼系統呼叫系統 江西省地圖標注 沈陽人工外呼系統價格 武漢外呼系統平臺 池州外呼調研線路 如何申請400電話費用 富錦商家地圖標注 沈陽防封電銷卡品牌

前言:

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

對比開始:

需求:畫出兩張子圖,在一行顯示,子圖中的內容一模一樣

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)#該方法會返回畫圖對象和坐標對象ax,figsize是設置子圖長寬(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()#添加圖列就是右上角的點說明

對比結果:

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

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

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

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

您可能感興趣的文章:
  • matplotlib subplots 設置總圖的標題方法
  • matplotlib subplots 調整子圖間矩的實例
  • Matplotlib 生成不同大小的subplots實例

標簽:呂梁 株洲 通遼 黑龍江 常德 潛江 銅川 阿里

巨人網絡通訊聲明:本文標題《Matplotlib實現subplot和subplots簡單對比》,本文關鍵詞  Matplotlib,實現,subplot,和,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Matplotlib實現subplot和subplots簡單對比》相關的同類信息!
  • 本頁收集關于Matplotlib實現subplot和subplots簡單對比的相關信息資訊供網民參考!
  • 推薦文章