我是靠谱客的博主 健康发带,这篇文章主要介绍python 子图大小_Python | 图的大小,现在分享给大家,希望可以做个参考。

python 子图大小

In some cases, the automatic figure size generated by the matplotlib.pyplot is not visually good or there could be some non-acceptable ratio in the figure. So, rather than allowing a pyplot to decide the figure size, we can manually define the dimensions of the figure.

在某些情况下,由matplotlib.pyplot生成的自动图形大小在视觉上不佳,或者图形中可能存在某些不可接受的比例。 因此,我们可以手动定义图形的尺寸,而不是允许pyplot来确定图形的尺寸。

In this article, we are going to change figure size using an inbuilt function:

在本文中,我们将使用内置函数更改图形大小

复制代码
1
2
matplotlib.pyplot.figure(figsize)

Syntax:

句法:

复制代码
1
2
3
4
matplotlib.pyplot.figure(figsize=(9,3)) # figsize(float, float) width, height in inches.

1)宽身材 (1) Wide Figure)

python | figure size of plot (1)

2)高地 (2) Tall Plot)

python | figure size of plot (2)

3)小方形图 (3) Small Square Figure)

python | figure size of plot (3)

4)方形图 (4) Square Figure)

python | figure size of plot (4)

绘图图形大小的Python代码 (Python code for figure size of plot)

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Data Visualization using Python # Figure Size import numpy as np import matplotlib.pyplot as plt x = np.arange(50) y = 2*x*x + 7*x - 14 # Example 1 plt.figure(figsize=(9,5)) # Leftmost plt.plot(x, y, 'yo') plt.title('Plot') plt.ylabel('Function Vaule') plt.xlabel('x-axis') plt.show() # Example 2 plt.figure(figsize=(6,9)) # Leftmost plt.plot(x, y, 'yo') plt.title('Plot') plt.ylabel('Function Vaule') plt.xlabel('x-axis') plt.show() # Example 3 plt.figure(figsize=(3,3)) # Leftmost plt.plot(x, y, 'yo') plt.title('Plot') plt.ylabel('Function Vaule') plt.xlabel('x-axis') plt.show() # Example 4 plt.figure(figsize=(7,7)) # Leftmost plt.plot(x, y, 'yo') plt.title('Plot') plt.ylabel('Function Vaule') plt.xlabel('x-axis') plt.show()

Output:

输出:

复制代码
1
2
Output is as figure

翻译自: https://www.includehelp.com/python/figure-size-of-plot.aspx

python 子图大小

最后

以上就是健康发带最近收集整理的关于python 子图大小_Python | 图的大小的全部内容,更多相关python内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(55)

评论列表共有 0 条评论

立即
投稿
返回
顶部