admin管理员组文章数量:1026989
I am making plots in a GUI using matplotlib. My original figure is large, and i would like ot be able to save a smaller version of the figure as a PDF (or PNG). I am able to do so by changing the figsize and then using figsave. However, by doing so, the relative dimensions of the elements change in the PDF, with different numbers on the axis (usually less), labels crashing, etc. Is there a way to change the size and save the figure while preserving the relative size and positions of all the elements?
fig_size = (8, min(3 * npanels,maxsize))
fig = Figure(figsize=fig_size, dpi=80)
for i in range(0, npanels):
ax = fig.add_subplot(npanels, 1, i + 1)
fig.set_size_inches(4.08, 4.08)
fig.savefig(fname=fname, dpi=80, format='pdf', papertype='letter',
facecolor=fig.get_facecolor(), edgecolor='none',
pad_inches=0.01, bbox_inches='tight')
Ok I even tried keeping the size constant (so not changing the chart size anymore) and the relative positons still move after PDFing (same DPI).
Here is the output in GUI: GUI Output
And Here is the PDF (notice how the relive positions change):
PDF Output
I am making plots in a GUI using matplotlib. My original figure is large, and i would like ot be able to save a smaller version of the figure as a PDF (or PNG). I am able to do so by changing the figsize and then using figsave. However, by doing so, the relative dimensions of the elements change in the PDF, with different numbers on the axis (usually less), labels crashing, etc. Is there a way to change the size and save the figure while preserving the relative size and positions of all the elements?
fig_size = (8, min(3 * npanels,maxsize))
fig = Figure(figsize=fig_size, dpi=80)
for i in range(0, npanels):
ax = fig.add_subplot(npanels, 1, i + 1)
fig.set_size_inches(4.08, 4.08)
fig.savefig(fname=fname, dpi=80, format='pdf', papertype='letter',
facecolor=fig.get_facecolor(), edgecolor='none',
pad_inches=0.01, bbox_inches='tight')
Ok I even tried keeping the size constant (so not changing the chart size anymore) and the relative positons still move after PDFing (same DPI).
Here is the output in GUI: GUI Output
And Here is the PDF (notice how the relive positions change):
PDF Output
本文标签:
版权声明:本文标题:python - Can I resize figure and preserve relative positionsdimensions of labels, legends, axis, ticks, etc? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1741633905a1879652.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论