我正试图在matplotlib
中创建一个在期刊文章中读得很好的数字。我有一些较大的数字(有子图),我想以纵向模式占据几乎整页(特别是6.5“x9”,整页数字,美国信纸上有1“边距)。我可以设置使用figsize
参数可以轻松调整图形大小。但是,如果我将图形尺寸设置为大于我的屏幕尺寸(我正在使用13英寸笔记本电脑),则会压缩图形。具体来说,高度是一个问题。只要下面的height
参数大于我的屏幕高度,保存的图形的尺寸就不会改变:
height = 9
fig, ax = plt.subplots(3, 2, figsize=(6.5, height))
plt.savefig('test.png') # size of this figure is independent of height
# if height > height of my screen
如果matplotlib
超出我的屏幕尺寸,我怎么能使用所要求的图形尺寸?我正在使用spyder。
这可能是您的后端生成情节的问题。
您可以通过运行来查看正在使用的后端:
import matplotlib; matplotlib.get_backend()
尝试将后端更改为其他内容,例如:
import matplotlib
matplotlib.use('Agg')
请注意,这必须在导入matplotlib.pyplot
之前运行。