使用 matplotlib 画图的保存方法有两种 | 您所在的位置:网站首页 › 有谁保存的有iicocacola图吗 › 使用 matplotlib 画图的保存方法有两种 |
使用 matplotlib 画图的保存方法有两种
方法一
使用 plt.savefig( ) 使用%matplotlib qt5 #弹出窗口,可以放大、缩小 注意:代码基于jupyter notebook 实现 import matplotlib.pyplot as plt %matplotlib qt5 #弹出窗口,可以放大、缩小 import numpy as np plt.rcParams['font.sans-serif']=['SimHei'] # 用来显示正常的中文标签 plt.rcParams['axes.unicode_minus'] = False #用来正常显示负号 x = np.linspace(0.05,10,1000) y = np.sin(x) plt.plot(x,y) ax = plt.gca() ax.spines['right'].set_color('red') ax.spines['left'].set_color('pink') ax.spines['top'].set_color('yellow') ax.spines['bottom'].set_color('green')使用该语句,弹出画图窗口,可以直接点击保存按钮即可。 |
CopyRight 2018-2019 实验室设备网 版权所有 |