網站首頁 編程語言 正文
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-03-14 移動端rem適配(rem怎么適配不同的手機)
- 2022-10-06 Python時間戳與日期格式之間相互轉化的詳細教程_python
- 2022-01-11 web:war 和 web:war exploded 遇到的坑
- 2022-03-16 .NET6導入和導出EXCEL_實用技巧
- 2022-04-09 Python中緩存lru_cache的基本介紹和講解_python
- 2022-06-01 C++的matlab接口轉換方法詳解_C 語言
- 2021-12-01 C語言中單目操作符++、–的實例講解_C 語言
- 2022-01-16 jQuery 核心函數css和平滑滾動頂部
- 最近更新
-
- 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同步修改后的遠程分支