本文共 1488 字,大约阅读时间需要 4 分钟。
python 子图大小
In some cases, the automatic figure size generated by the 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.
在某些情况下,由生成的自动图形大小在视觉上不佳,或者图形中可能存在某些不可接受的比例。 因此,我们可以手动定义图形的尺寸,而不是允许pyplot来确定图形的尺寸。
In this article, we are going to change figure size using an inbuilt function:
在本文中,我们将使用内置函数来更改图形大小 :
matplotlib.pyplot.figure(figsize)
Syntax:
句法:
matplotlib.pyplot.figure(figsize=(9,3))# figsize(float, float) width, height in inches.
# Data Visualization using Python# Figure Sizeimport numpy as npimport matplotlib.pyplot as pltx = np.arange(50)y = 2*x*x + 7*x - 14# Example 1 plt.figure(figsize=(9,5))# Leftmostplt.plot(x, y, 'yo')plt.title('Plot')plt.ylabel('Function Vaule')plt.xlabel('x-axis')plt.show()# Example 2 plt.figure(figsize=(6,9))# Leftmostplt.plot(x, y, 'yo')plt.title('Plot')plt.ylabel('Function Vaule')plt.xlabel('x-axis')plt.show()# Example 3plt.figure(figsize=(3,3))# Leftmostplt.plot(x, y, 'yo')plt.title('Plot')plt.ylabel('Function Vaule')plt.xlabel('x-axis')plt.show()# Example 4 plt.figure(figsize=(7,7))# Leftmostplt.plot(x, y, 'yo')plt.title('Plot')plt.ylabel('Function Vaule')plt.xlabel('x-axis')plt.show()
Output:
输出:
Output is as figure
翻译自:
python 子图大小
转载地址:http://jyxzd.baihongyu.com/