我正在使用以下代码将 .png 拼接成来自 MATPLOTLIB 的散点图。不幸的是,插图的图像质量很糟糕。我该如何解决这个问题?
png_file = open("blah.png",'r')
arr_lena = read_png(png_file)
imagebox = OffsetImage(arr_lena, zoom=0.2)
ab = AnnotationBbox(imagebox, (99.17,68.006),
xybox=(100,0.),
xycoords='data',
boxcoords="offset points",
pad=0.5,
arrowprops=dict(arrowstyle="->",
connectionstyle="angle,angleA=0,angleB=90,rad=3")
)
ax.add_artist(ab)
最佳答案
保存图形时,可以设置dpi
。这修复了 png
图像的质量。例如:
plt.savefig('my_figure.pdf', bbox_inches='tight', dpi=400)
关于python - MATPLOTLIB 中的 read_png 是模糊的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21393588/