Matplotlib保存SVG时绘图超画布边界问题及矢量图格式疑问
SVG保存时绘图超出画布边界问题
我将图像保存为.svg文件时,绘图超出了画布边界,但保存为png文件时无此问题。原本以为ax.set_xlim(xmin,xmax)会作为绘图的边界,无论保存为何种文件类型。
相关代码如下:
%matplotlib qt fig, ax = plt.subplots(constrained_layout=True) xmin,xmax= 350,800 # ############################################################################################################ x = np.arange(200,900,1) y = np.random.rand(len(x)) ax.plot(x,y,label="noise") ############################################################################################################# leg = ax.legend(loc="upper right") ax.set_ylim(-0.02,2) ax.set_xlim(xmin,xmax) plt.show()
补充说明:
- 我使用SVG是因为需要矢量图用于LibreOffice Impress;
- 也想用于PowerPoint,但似乎它不支持矢量图?或许我应该改用其他文件类型?
内容的提问来源于stack exchange,提问作者Martin
相关产品推荐
相关产品推荐

