網站首頁 編程語言 正文
matplotlib繪圖時是默認的大小,有時候默認的大小會感覺圖片里的內容都被壓縮了,解決方法如下。
先是原始代碼:
from matplotlib import pyplot as plt
plt.figure(figsize=(1,1))
x = [1,2,3]
plt.plot(x, x)
plt.show()
關鍵的代碼是plt.figure(figsize=(1,1)),生成的圖片如下
修改代碼,放大圖片:
from matplotlib import pyplot as plt
plt.figure(figsize=(10,10))
x = [1,2,3]
plt.plot(x, x)
plt.show()
這時候橫坐標和縱坐標都放大了10倍:
如果想要指定像素,可以這么做:
from matplotlib import pyplot as plt
plt.figure(dpi=80)
x = [1,2,3]
plt.plot(x, x)
plt.show()
更多參考資料:python - How do you change the size of figures drawn with matplotlib? - Stack Overflow
附:matplotlib繪圖時橫縱坐標和圖例的字體大小如何設置
橫縱坐標字體大小調節:
通過fontsize可以進行調節
ax1.set_ylabel("AUC",fontsize=20)
ax2.set_ylabel("Logloss",fontsize=20)
圖例字體大小調節:
在plt.legend中加一個
prop={"size":18,"weight":"black"}
即可
總結
原文鏈接:https://zhang0peter.blog.csdn.net/article/details/90734660
相關推薦
- 2022-04-27 分布式Redis?Cluster集群搭建與Redis基本用法_Redis
- 2022-12-09 Python?hashlib模塊詳細講解使用方法_python
- 2023-03-27 Python中反轉二維數組的行和列問題_python
- 2022-03-27 MongoDB的常用命令匯總(Mongo4.2.8)_MongoDB
- 2022-08-07 使用pd.merge表連接出現多余行的問題解決_python
- 2022-09-16 JQuery實現電梯導航效果_jquery
- 2022-11-21 初識React及React開發依賴詳解_React
- 2022-07-06 使用client?go實現自定義控制器的方法_Golang
- 最近更新
-
- 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同步修改后的遠程分支