Matplotlib |将方向更改为portrai

2024-10-03 04:37:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我有这张纸条在同一页上绘制7系列。我想将页面方向设置为纵向。如下图所示,我尝试了:

f.savefig(sta+'.pdf', orientation='portrait', format='pdf')

但什么也没发生!在

你有什么建议吗?在

^{pr2}$

提前感谢:-)


Tags: formatpdf绘制页面方向建议orientationsavefig
1条回答
网友
1楼 · 发布于 2024-10-03 04:37:36

我想你是想改变图形大小,而不是与页面布局有关。orientationkwarg to savefig实际上只适用于PS和EPS后端。对于PDF,页面大小被定义为等于图形大小,因此它没有任何效果。在

作为当前结果的一个简单示例:

import matplotlib.pyplot as plt
fig, ax = plt.subplots(nrows=7, sharex=True, sharey=False)
fig.subplots_adjust(hspace=0.5)
plt.show()

enter image description here

要更改图形的大小,请使用figsizekwarg:

^{pr2}$

enter image description here

相关问题 更多 >