欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Matplotlib中rcParams使用方法

 更新時(shí)間:2021年01月05日 10:15:27   作者:LthID  
這篇文章主要介紹了Matplotlib中rcParams使用方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

主要作用為指定圖片像素:

matplotlib.rcParams[‘figure.figsize']#圖片像素 
matplotlib.rcParams[‘savefig.dpi']#分辨率 
plt.savefig(‘plot123_2.png', dpi=200)#指定分辨率
%matplotlib inline
import matplotlib # 注意這個(gè)也要import一次
import matplotlib.pyplot as plt
from IPython.core.pylabtools import figsize # import figsize
#figsize(12.5, 4) # 設(shè)置 figsize
plt.rcParams['savefig.dpi'] = 300 #圖片像素
plt.rcParams['figure.dpi'] = 300 #分辨率
# 默認(rèn)的像素:[6.0,4.0],分辨率為100,圖片尺寸為 600&400
# 指定dpi=200,圖片尺寸為 1200*800
# 指定dpi=300,圖片尺寸為 1800*1200
# 設(shè)置figsize可以在不改變分辨率情況下改變比例

myfont = matplotlib.font_manager.FontProperties(fname=r'C:/Windows/Fonts/msyh.ttf') # 這一行
plt.plot((1,2,3),(4,3,-1))
plt.xlabel(u'橫坐標(biāo)', fontproperties=myfont) # 這一段
plt.ylabel(u'縱坐標(biāo)', fontproperties=myfont) # 這一段
#plt.show()
plt.savefig('plot123_2.png', dpi=300) #指定分辨率保存

這里寫圖片描述

一樣的圖片,像素大就更加高清了。

Matplotlib中plt.rcParams用法(設(shè)置圖像細(xì)節(jié))

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
%matplotlib inline  

# 生成數(shù)據(jù)
x = np.linspace(0, 4*np.pi)
y = np.sin(x)

plt.rcParams['figure.figsize'] = (5.0, 4.0)   # 顯示圖像的最大范圍
plt.rcParams['image.interpolation'] = 'nearest' # 差值方式,設(shè)置 interpolation style
plt.rcParams['image.cmap'] = 'gray'       # 灰度空間

#設(shè)置rc參數(shù)顯示中文標(biāo)題
#設(shè)置字體為SimHei顯示中文
plt.rcParams['font.sans-serif'] = 'SimHei'
#設(shè)置正常顯示字符
plt.rcParams['axes.unicode_minus'] = False
plt.title('sin曲線')
#設(shè)置線條樣式
plt.rcParams['lines.linestyle'] = '-.'
#設(shè)置線條寬度
plt.rcParams['lines.linewidth'] = 3
#繪制sin曲線
plt.plot(x, y, label='$sin(x)$')
 
# plt.savefig('sin.png')
# plt.show()


x=np.array([1,2])
y=np.array([1,4])
z=np.array([[1,2], [3, 4]])
plt.xlim(1,2)
plt.ylim(1,4)

plt.contourf(x, y, z, alpha=0.6)  

到此這篇關(guān)于Matplotlib中rcParams使用方法的文章就介紹到這了,更多相關(guān)Matplotlib rcParams使用內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論