有没有办法使用PIL和matplotlib将EPS或SVG(或任何可伸缩矢量格式)中的标志放置在图形上,并将最终文件输出为EPS。现在,我得到了一个极其糟糕的渲染图形,因为有一个.png文件试图被转换为EPS格式,而目标是将图像保存为.eps或.svg。
我认为这可能是由于后端的限制,我可以更改使用哪个后端。
以下内容无法正常工作:
ax1.set_axis_bgcolor('#fafafa')
img = image.imread('./static/images/logo.png')
image_axis = fig.add_axes(ax1.get_position())
image_axis.patch.set_visible(False)
image_axis.yaxis.set_visible(False)
image_axis.xaxis.set_visible(False)
image_axis.set_xlim(0,19.995)
image_axis.set_ylim(0,11.25)
image_axis.imshow(img, extent=(11.79705,18.99525,.238125,1.313625), zorder=-1, alpha=0.15) #need to keep a 5.023 x by y ratio (.4 x .079)
fig.savefig('static/images/graphs/'+filename+'.eps', format='eps', bbox_inches='tight')
有更新吗?
imshow
的图像是非PNG格式,matplotlib将会退而求其次使用PIL来处理EPS文件(文档)。我手头没有EPS文件可以测试,但明天可以尝试一下。 - J Richard Snape