網(wǎng)站首頁(yè) 編程語(yǔ)言 正文
plt.subplot()
plt.subplot(nrows, ncols, index, **kwargs)
第一個(gè)參數(shù):*args (官網(wǎng)文檔描述)
Either a 3-digit integer or three separate integers describing the position of the subplot. If the three integers are nrows, ncols, and index in order, the subplot will take the index position on a grid with nrows rows and ncols columns. index starts at 1 in the upper left corner and increases to the right.
可以使用三個(gè)整數(shù),或者三個(gè)獨(dú)立的整數(shù)來描述子圖的位置信息。如果三個(gè)整數(shù)是行數(shù)、列數(shù)和索引值,子圖將分布在行列的索引位置上。索引從1開始,從右上角增加到右下角。
pos is a three digit integer, where the first digit is the number of rows, the second the number of columns, and the third the index of the subplot. i.e. fig.add_subplot(235) is the same as fig.add_subplot(2, 3, 5). Note that all integers must be less than 10 for this form to work.
位置是由三個(gè)整型數(shù)值構(gòu)成,第一個(gè)代表行數(shù),第二個(gè)代表列數(shù),第三個(gè)代表索引位置。舉個(gè)列子:plt.subplot(2, 3, 5) 和 plt.subplot(235) 是一樣一樣的。需要注意的是所有的數(shù)字不能超過10。
第二個(gè)參數(shù):projection : {None, ‘a(chǎn)itoff’, ‘hammer’, ‘lambert’, ‘mollweide’, ‘polar’, ‘rectilinear’, str}, optional
The projection type of the subplot (Axes). str is the name of a costum projection, see projections. The default None results in a ‘rectilinear’ projection.
可選參數(shù):可以選擇子圖的類型,比如選擇polar,就是一個(gè)極點(diǎn)圖。默認(rèn)是none就是一個(gè)線形圖。
第三個(gè)參數(shù):polar : boolean, optional
If True, equivalent to projection=‘polar’. 如果選擇true,就是一個(gè)極點(diǎn)圖,上一個(gè)參數(shù)也能實(shí)現(xiàn)該功能。
官方文檔傳送門:plt.subplot()
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(1, 2, 2)
y1 = np.sin(x)
y2 = np.cos(x)
ax1 = plt.subplot(2, 2, 1, frameon = False) # 兩行一列,位置是1的子圖
plt.plot(x, y1, 'b--')
plt.ylabel('y1')
ax2 = plt.subplot(2, 2, 2, projection = 'polar')
plt.plot(x, y2, 'r--')
plt.ylabel('y2')
plt.xlabel('x')
plt.subplot(2, 2, 3, sharex = ax1, facecolor = 'red')
plt.plot(x, y2, 'r--')
plt.ylabel('y2')
plt.show()
以上代碼畫圖如下:
可以看到plt.subplot()可以依次畫出這些子圖,優(yōu)點(diǎn)是簡(jiǎn)單明了,缺點(diǎn)是略顯麻煩。
原文鏈接:https://laoai.blog.csdn.net/article/details/90543210
相關(guān)推薦
- 2022-06-07 Python接口自動(dòng)化之文件上傳/下載接口詳解_python
- 2022-07-30 golang?redis中Pipeline通道的使用詳解_Golang
- 2022-01-27 SpringBoot成功啟動(dòng)后自動(dòng)關(guān)閉
- 2023-11-12 ip link set eno2 down后centos無法聯(lián)網(wǎng);centos7.0,二次啟動(dòng)后無法
- 2023-04-12 在redis中防止消息丟失的機(jī)制_Redis
- 2022-04-01 HIVE nvl 空值轉(zhuǎn)換函數(shù)
- 2022-04-02 Android中Button實(shí)現(xiàn)點(diǎn)擊換圖案及顏色_Android
- 2022-08-11 如何利用python繪制等高線圖_python
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支