網(wǎng)站首頁 編程語言 正文
1. 函數(shù)功能
調(diào)整子區(qū)的展現(xiàn)效果
2. 函數(shù)語法
subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)
3. 函數(shù)參數(shù)與示例
參數(shù) | 含義 |
---|---|
left | 可選參數(shù),浮點(diǎn)數(shù);子區(qū)左邊的位置,默認(rèn)為 0.125,以畫布figure為參考系 |
right | 可選參數(shù),浮點(diǎn)數(shù);子區(qū)右邊的位置 ,默認(rèn)為 0.9,以畫布figure為參考系 |
bottom | 可選參數(shù),浮點(diǎn)數(shù);子區(qū)底邊的位置,默認(rèn)為 0.11,以畫布figure為參考系 |
top | 可選參數(shù),浮點(diǎn)數(shù);子區(qū)頂邊的位置,默認(rèn)為 0.88,以畫布figure為參考系 |
wspace | 可選參數(shù),浮點(diǎn)數(shù);子區(qū)之間的空白寬度,默認(rèn)為 0.2,以繪圖區(qū)的平均寬度為參考 |
hspace | 可選參數(shù),浮點(diǎn)數(shù);子區(qū)之間的空白高度,默認(rèn)為 0.2,以繪圖區(qū)的平均寬度為參考 |
3.1 hsapce
import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl
mpl.rcParams['font.sans-serif'] = ['KaiTi']
mpl.rcParams['axes.unicode_minus'] = False
x = np.linspace(0, 2 * np.pi, 500)
y1 = np.sin(x) * np.cos(x)
y2 = np.exp(-x)
y3 = np.sqrt(x)
y4 = x / 4
fig, ax = plt.subplots(4, 1, facecolor='beige', sharex=True,
subplot_kw=dict(facecolor='seashell'))
ax[0].plot(x, y1, c='r', lw=2)
ax[1].plot(x, y2, c='y', ls="--")
ax[2].plot(x, y3, c='g', ls=":")
ax[3].plot(x, y4, c='m', ls='-.', lw=2)
plt.show()
對(duì)于本例中的圖形,所有圖形共享x軸,則圖形與圖形之間不需要空隙,垂直方向的空隙可以通過hspace=0,實(shí)現(xiàn)消除
import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl
mpl.rcParams['font.sans-serif'] = ['KaiTi']
mpl.rcParams['axes.unicode_minus'] = False
x = np.linspace(0, 2 * np.pi, 500)
y1 = np.sin(x) * np.cos(x)
y2 = np.exp(-x)
y3 = np.sqrt(x)
y4 = x / 4
fig, ax = plt.subplots(4, 1, facecolor='beige', sharex=True,
subplot_kw=dict(facecolor='seashell'))
fig.subplots_adjust(hspace=0)
ax[0].plot(x, y1, c='r', lw=2)
ax[1].plot(x, y2, c='y', ls="--")
ax[2].plot(x, y3, c='g', ls=":")
ax[3].plot(x, y4, c='m', ls='-.', lw=2)
plt.show()
3.2 left right bottom top
import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl
mpl.rcParams['font.sans-serif'] = ['KaiTi']
mpl.rcParams['axes.unicode_minus'] = False
x = np.linspace(0, 2 * np.pi, 500)
y1 = np.sin(x) * np.cos(x)
y2 = np.exp(-x)
y3 = np.sqrt(x)
y4 = x / 4
fig, ax = plt.subplots(4, 1, facecolor='beige', sharex=True,
subplot_kw=dict(facecolor='seashell'))
fig.subplots_adjust(left=0.05, right=0.98, bottom=0.05,
top=0.95, hspace=0)
ax[0].plot(x, y1, c='r', lw=2)
ax[1].plot(x, y2, c='y', ls="--")
ax[2].plot(x, y3, c='g', ls=":")
ax[3].plot(x, y4, c='m', ls='-.', lw=2)
plt.show()
原文鏈接:https://blog.csdn.net/chongbaikaishi/article/details/127578822
相關(guān)推薦
- 2022-05-12 Android10 分享微信提示獲取資源失敗
- 2022-06-20 關(guān)于Golang獲取當(dāng)前項(xiàng)目絕對(duì)路徑的問題_Golang
- 2022-11-01 Kotlin?ContentProvider使用方法介紹_Android
- 2023-05-11 C#利用OLEDB實(shí)現(xiàn)將DataTable寫入Excel文件中_C#教程
- 2022-07-17 C++深入講解new與deleted關(guān)鍵字的使用_C 語言
- 2022-10-25 linux服務(wù)器校對(duì)時(shí)間方法命令詳解_Linux
- 2022-06-12 淺談Android?Dialog窗口機(jī)制_Android
- 2022-04-14 CMake編譯中的庫文件和頭文件鏈接你了解嗎_C 語言
- 最近更新
-
- 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)程分支