我已经使用 matplotlib 绘制了一些实验结果(在这里讨论过: Looping over files and plotting 。但是,通过在图像上单击右键来保存图片会产生非常差的质量/低分辨率图像。
from glob import glob
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
# loop over all files in the current directory ending with .txt
for fname in glob("./*.txt"):
# read file, skip header (1 line) and unpack into 3 variables
WL, ABS, T = np.genfromtxt(fname, skip_header=1, unpack=True)
# first plot
plt.plot(WL, T, label='BN', color='blue')
plt.xlabel('Wavelength (nm)')
plt.xlim(200,1000)
plt.ylim(0,100)
plt.ylabel('Transmittance, %')
mpl.rcParams.update({'font.size': 14})
#plt.legend(loc='lower center')
plt.title('')
plt.show()
plt.clf()
# second plot
plt.plot(WL, ABS, label='BN', color='red')
plt.xlabel('Wavelength (nm)')
plt.xlim(200,1000)
plt.ylabel('Absorbance, A')
mpl.rcParams.update({'font.size': 14})
#plt.legend()
plt.title('')
plt.show()
plt.clf()
我正在寻找的示例图: example graph
原文由 esilik 发布,翻译遵循 CC BY-SA 4.0 许可协议
您可以使用
savefig()
导出到图像文件:此外,您可以将
dpi
参数指定为某个标量值,例如: