当前位置:网站首页>PLT in Matplotlib tight_ layout()
PLT in Matplotlib tight_ layout()
2022-07-06 08:21:00 【It's a dream, it's you!】
Catalog
4 add plt.tight_layout() after
1 problem
(1) stay matplotlib in , Axis domain ( Including subgraphs ) The position of the is specified in standardized drawing coordinates . What may happen is , Your axis label or title ( Sometimes even scale labels ) It will exceed the graphic area , Therefore, it is truncated .
(2) When you have multiple subgraphs , You will often see labels of different axis fields stacked together .
2 resolvent
# stay plt.show() with :
plt.tight_layout()
3 Case study
3.1 Code
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import matplotlib; matplotlib.use('TkAgg')
mpl.rcParams['font.sans-serif'] = ['SimHei'] # Specify default font
mpl.rcParams['axes.unicode_minus'] = False # Resolve save image is negative '-' Questions displayed as squares
plt.rcParams['savefig.facecolor'] = "0.8"
def example_plot(ax, fontsize=12):
ax.plot([1, 2])
ax.locator_params(nbins=3)
ax.set_xlabel('x-label', fontsize=fontsize)
ax.set_ylabel('y-label', fontsize=fontsize)
ax.set_title('Title', fontsize=fontsize)
plt.close('all')
plt.close('all')
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(nrows=2, ncols=2)
example_plot(ax1)
example_plot(ax2)
example_plot(ax3)
example_plot(ax4)
plt.show()
3.2 result
4 add plt.tight_layout() after
4.1 Code
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import matplotlib; matplotlib.use('TkAgg')
mpl.rcParams['font.sans-serif'] = ['SimHei'] # Specify default font
mpl.rcParams['axes.unicode_minus'] = False # Resolve save image is negative '-' Questions displayed as squares
plt.rcParams['savefig.facecolor'] = "0.8"
def example_plot(ax, fontsize=12):
ax.plot([1, 2])
ax.locator_params(nbins=3)
ax.set_xlabel('x-label', fontsize=fontsize)
ax.set_ylabel('y-label', fontsize=fontsize)
ax.set_title('Title', fontsize=fontsize)
plt.close('all')
plt.close('all')
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(nrows=2, ncols=2)
example_plot(ax1)
example_plot(ax2)
example_plot(ax3)
example_plot(ax4)
plt.tight_layout()
plt.show()
4.2 result
边栏推荐
- matplotlib. Widgets are easy to use
- Database basic commands
- "Friendship and righteousness" of the center for national economy and information technology: China's friendship wine - the "unparalleled loyalty and righteousness" of the solidarity group released th
- Yyds dry goods inventory three JS source code interpretation eventdispatcher
- 你想知道的ArrayList知识都在这
- Mobile Test Engineer occupation yyds dry goods inventory
- synchronized 解决共享带来的问题
- [research materials] 2022 China yuancosmos white paper - Download attached
- CAD ARX 获取当前的视口设置
- 指针和数组笔试题解析
猜你喜欢
[t31zl intelligent video application processor data]
A Closer Look at How Fine-tuning Changes BERT
[Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map
让学指针变得更简单(三)
C语言自定义类型:结构体
matplotlib. Widgets are easy to use
你想知道的ArrayList知识都在这
Learn Arduino with examples
Nacos Development Manual
It's hard to find a job when the industry is in recession
随机推荐
IP lab, the first weekly recheck
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Migrate data from a tidb cluster to another tidb cluster
[Yugong series] February 2022 U3D full stack class 010 prefabricated parts
1. Color inversion, logarithmic transformation, gamma transformation source code - miniopencv from zero
【T31ZL智能视频应用处理器资料】
Yyds dry goods inventory three JS source code interpretation eventdispatcher
Restore backup data on S3 compatible storage with tidb lightning
Permutation and combination function
Summary of MySQL index failure scenarios
IoT -- 解读物联网四层架构
"Designer universe": "benefit dimension" APEC public welfare + 2022 the latest slogan and the new platform will be launched soon | Asia Pacific Financial Media
Résumé des diagrammes de description des broches de la série ESP
Epoll and IO multiplexing of redis
Ruffian Heng embedded bimonthly, issue 49
wincc7.5下载安装教程(Win10系统)
From monomer structure to microservice architecture, introduction to microservices
The Vice Minister of the Ministry of industry and information technology of "APEC industry +" of the national economic and information technology center led a team to Sichuan to investigate the operat
Upgrade tidb with tiup
ESP series pin description diagram summary