網站首頁 編程語言 正文
1. 函數功能
調整子區的展現效果
2. 函數語法
subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)
3. 函數參數與示例
參數 | 含義 |
---|---|
left | 可選參數,浮點數;子區左邊的位置,默認為 0.125,以畫布figure為參考系 |
right | 可選參數,浮點數;子區右邊的位置 ,默認為 0.9,以畫布figure為參考系 |
bottom | 可選參數,浮點數;子區底邊的位置,默認為 0.11,以畫布figure為參考系 |
top | 可選參數,浮點數;子區頂邊的位置,默認為 0.88,以畫布figure為參考系 |
wspace | 可選參數,浮點數;子區之間的空白寬度,默認為 0.2,以繪圖區的平均寬度為參考 |
hspace | 可選參數,浮點數;子區之間的空白高度,默認為 0.2,以繪圖區的平均寬度為參考 |
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()
對于本例中的圖形,所有圖形共享x軸,則圖形與圖形之間不需要空隙,垂直方向的空隙可以通過hspace=0,實現消除
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
- 上一篇:Spring的純注解配置詳解
- 下一篇:Centos8系統配置Redis實現開機自啟
相關推薦
- 2022-09-18 Docker?Compose?搭建簡單的Python網絡應用程序(步驟詳解)_docker
- 2022-07-19 Eureka注冊中心之搭建eureka-server
- 2022-12-06 React-Hook中使用useEffect清除定時器的實現方法_React
- 2022-10-20 Android開發使用RecyclerView添加點擊事件實例詳解_Android
- 2022-10-27 golang?map的基本操作及定義方式_Golang
- 2022-07-13 kafka中Topic、消費組以及消息狀態詳解
- 2022-03-28 Python?format字符串格式化函數的使用_python
- 2022-05-15 Redis中有序集合的內部實現方式的詳細介紹_Redis
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支