Python:A4 大小的绘图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15571267/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python: A4 size for a plot
提问by Py-ser
I have a code that saves a figure with:
我有一个代码可以保存一个数字:
savefig("foo.eps", orientation = 'portrait', format = 'eps')
If I don't specify anythingelse, the figure is correctly saved but when I print it, the figure fills only the half of a A4 sheet.If I modify the string as:
如果我不指定任何其他内容,则该图已正确保存,但是当我打印它时,该图仅填充了 A4 纸的一半。如果我将字符串修改为:
savefig("foo.eps", papertype = 'a4', orientation = 'portrait', format = 'eps')
Nothing chages! How can I set the size of the figure in a way that it fills the whole A4 sheet? Many thanks in advance.
没什么变化!如何以填充整个 A4 纸的方式设置图形的大小?提前谢谢了。
采纳答案by askewchan
Try to set the size of the figure (in inches) before you save it. You can do this when you initialize the figure by doing:
在保存之前尝试设置图形的大小(以英寸为单位)。您可以在通过执行以下操作初始化图形时执行此操作:
figure(figsize=(11.69,8.27)) # for landscape
or if the figure exists:
或者如果该图存在:
f = gcf() # f = figure(n) if you know the figure number
f.set_size_inches(11.69,8.27)
or in advance for all plots, using
或提前为所有地块,使用
rc('figure', figsize=(11.69,8.27))

