Home > Backend Development > Python Tutorial > How to change matplotlib image size

How to change matplotlib image size

anonymity
Release: 2019-05-25 14:15:22
Original
6779 people have browsed it

Matplotlib is a plotting library for Python. It works with NumPy, providing an effective open source alternative to MatLab. It can also be used with graphical toolkits such as PyQt and wxPython.

How to change matplotlib image size

#For image size, Matplotlib provides the following methods to handle it.

matplotlib.rcParams['figure.figsize']#Picture pixels

matplotlib.rcParams['savefig.dpi']#Resolution

plt.savefig ('plot123_2.png', dpi=200)#Specify resolution

Sample code:

plt.rcParams['figure.figsize'] = (8.0, 4.0) # 设置figure_size尺寸
plt.rcParams['image.interpolation'] = 'nearest' # 设置 interpolation style
plt.rcParams['image.cmap'] = 'gray' # 设置 颜色 style
#figsize(12.5, 4) # 设置 figsize
plt.rcParams['savefig.dpi'] = 300 #图片像素
plt.rcParams['figure.dpi'] = 300 #分辨率
# 默认的像素:[6.0,4.0],分辨率为100,图片尺寸为 600&400
# 指定dpi=200,图片尺寸为 1200*800
# 指定dpi=300,图片尺寸为 1800*1200
# 设置figsize可以在不改变分辨率情况下改变比例
Copy after login

The above is the detailed content of How to change matplotlib image size. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template