久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

Python plt 利用subplot 實現在一張畫布同時畫多張圖

瀏覽:68日期:2022-06-27 09:08:03
subplot(arg1, arg2, arg3)

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

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

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

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

Python plt 利用subplot 實現在一張畫布同時畫多張圖

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

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

import matplotlib.pyplot as pltimport seaborn as snssns.set()# 要分析的數據profit = df_profit.groupby(’release_year’)[’profit’].agg([’mean’,’sum’,’count’])# 在同一個畫布中繪制兩張圖plt.figure(figsize=(15,15))# 圖一:每年上映電影的總收入ax = plt.subplot(211)# 設置x軸 范圍ax.set_xlim(1958,2018)# 設置x軸 主刻度,(次刻度設置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)# 設置x軸 范圍ax.set_xlim(1958,2018)# 設置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);

Python plt 利用subplot 實現在一張畫布同時畫多張圖

Python plt 利用subplot 實現在一張畫布同時畫多張圖

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持好吧啦網。如有錯誤或未考慮完全的地方,望不吝賜教。

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 玛多县| 金沙县| 嵊州市| 泌阳县| 望谟县| 盈江县| 五台县| 安国市| 蒲城县| 通海县| 浮梁县| 武强县| 宜川县| 宾川县| 阿拉善左旗| 安西县| 永康市| 霍城县| 肥西县| 云浮市| 山阴县| 清远市| 澄江县| 法库县| 沛县| 凭祥市| 黄平县| 溆浦县| 太白县| 阿拉尔市| 华亭县| 昂仁县| 宁远县| 吉水县| 江门市| 灵石县| 吴川市| 秦安县| 新田县| 泾源县| 驻马店市|