当前位置:网站首页>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
边栏推荐
- ESP series pin description diagram summary
- Learn Arduino with examples
- 3. File operation 3-with
- Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation
- Flash return file download
- Golang DNS 随便写写
- Golang DNS write casually
- How to use information mechanism to realize process mutual exclusion, process synchronization and precursor relationship
- Circuit breaker: use of hystrix
- [luatos-air551g] 6.2 repair: restart caused by line drawing
猜你喜欢
【T31ZL智能视频应用处理器资料】
Summary of phased use of sonic one-stop open source distributed cluster cloud real machine test platform
Analysis of pointer and array written test questions
Fibonacci sequence
Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center
23. Update data
How to use information mechanism to realize process mutual exclusion, process synchronization and precursor relationship
"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
Nft智能合约发行,盲盒,公开发售技术实战--拼图篇
What is the use of entering the critical point? How to realize STM32 single chip microcomputer?
随机推荐
[untitled]
Secure captcha (unsafe verification code) of DVWA range
All the ArrayList knowledge you want to know is here
On why we should program for all
Migrate data from SQL files to tidb
C language - bit segment
PHP - Common magic method (nanny level teaching)
Ruffian Heng embedded bimonthly, issue 49
化不掉的钟薛高,逃不出网红产品的生命周期
On the day of resignation, jd.com deleted the database and ran away, and the programmer was sentenced
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
Asia Pacific Financial Media | female pattern ladyvision: forced the hotel to upgrade security. The drunk woman died in the guest room, and the hotel was sentenced not to pay compensation | APEC secur
Go learning notes (3) basic types and statements (2)
将 NFT 设置为 ENS 个人资料头像的分步指南
Golang DNS write casually
matplotlib. Widgets are easy to use
ESP系列引脚说明图汇总
Circuit breaker: use of hystrix
1204 character deletion operation (2)
Wincc7.5 download and installation tutorial (win10 system)