濮阳杆衣贸易有限公司

主頁 > 知識庫 > Python plt 利用subplot 實現(xiàn)在一張畫布同時畫多張圖

Python plt 利用subplot 實現(xiàn)在一張畫布同時畫多張圖

熱門標簽:螳螂科技外呼系統(tǒng)怎么用 400電話申請資格 舉辦過冬奧會的城市地圖標注 正安縣地圖標注app 阿里電話機器人對話 地圖地圖標注有嘆號 遼寧智能外呼系統(tǒng)需要多少錢 電銷機器人系統(tǒng)廠家鄭州 qt百度地圖標注

subplot(arg1, arg2, arg3)

arg1: 在垂直方向同時畫幾張圖

arg2: 在水平方向同時畫幾張圖

arg3: 當前命令修改的是第幾張圖

plt.figure()另起一張新的畫布
from PIL import Image
import matplotlib.pyplot as plt
image1 = Image.open('1.jpg')
image2 = Image.open('2.jpg')
plt.subplot(121) 
plt.imshow(image1)
plt.subplot(122) 
plt.imshow(image2)
plt.show() 

補充:matplotlib 同一個畫布繪制多張圖,主次刻度,豎線

我就廢話不多說了,大家還是直接看代碼吧~

import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
# 要分析的數(shù)據(jù)
profit = df_profit.groupby('release_year')['profit'].agg(['mean','sum','count'])
# 在同一個畫布中繪制兩張圖
plt.figure(figsize=(15,15))
# 圖一:每年上映電影的總收入
ax = plt.subplot(211)
# 設(shè)置x軸 范圍
ax.set_xlim(1958,2018)
# 設(shè)置x軸 主刻度,(次刻度設(shè)置minor=True)
ax.set_xticks(np.arange(1960,2018,5), minor=False)
# 畫圖
ax.plot(profit['sum'], linestyle='--', marker='o', markersize=5)
ax.set_title('The Sum of Movies\' Revenue v.s. Release Year')
ax.set_ylabel('Revenue(USD)')
# 增加豎線
ax.axvline(x=1977, color='#d46061', linewidth=1);
# 圖二:每年上映電影的平均收入
ax = plt.subplot(212)
# 設(shè)置x軸 范圍
ax.set_xlim(1958,2018)
# 設(shè)置x軸 主刻度
ax.set_xticks(np.arange(1960,2018,5))
# 畫圖
ax.plot(profit['mean'], linestyle='--', marker='o', markersize=5);
ax.set_title('The Mean of Movies' Revenue v.s. Release Year')
ax.set_xlabel('Release Year')
ax.set_ylabel('Revenue(USD)')
# 增加豎線
ax.axvline(x=1977, color='#d46061', linewidth=1);

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。如有錯誤或未考慮完全的地方,望不吝賜教。

您可能感興趣的文章:
  • Python使用add_subplot與subplot畫子圖操作示例
  • python matplotlib中的subplot函數(shù)使用詳解
  • Python figure參數(shù)及subplot子圖繪制代碼
  • python使用matplotlib:subplot繪制多個子圖的示例
  • python中subplot大小的設(shè)置步驟

標簽:淘寶好評回訪 濟源 合肥 昭通 興安盟 信陽 隨州 阜新

巨人網(wǎng)絡通訊聲明:本文標題《Python plt 利用subplot 實現(xiàn)在一張畫布同時畫多張圖》,本文關(guān)鍵詞  Python,plt,利用,subplot,實,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Python plt 利用subplot 實現(xiàn)在一張畫布同時畫多張圖》相關(guān)的同類信息!
  • 本頁收集關(guān)于Python plt 利用subplot 實現(xiàn)在一張畫布同時畫多張圖的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    镇巴县| 偏关县| 澜沧| 和林格尔县| 武夷山市| 溆浦县| 东台市| 济宁市| 福州市| 横山县| 德安县| 丹阳市| 达日县| 于都县| 鸡泽县| 潼关县| 响水县| 阳东县| 黔西| 北安市| 青河县| 神农架林区| 富裕县| 虞城县| 达日县| 桑植县| 大方县| 长宁县| 海口市| 揭阳市| 东兰县| 岑溪市| 宜州市| 汶上县| 景德镇市| 松江区| 巩留县| 九龙坡区| 宁明县| 凤阳县| 衡东县|