[英]High resolution figure when using the axes method for subplots in matplotlib
When creating a figure using plt.figure , one can set its size and resolution in the following way:使用plt.figure创建图形时,可以通过以下方式设置其大小和分辨率:
plt.figure(num=1, figsize=(6, 4), dpi=150)
How can this be obtained when creating a figure using the following code?使用以下代码创建图形时如何获得?
fig, ax = plt.subplots()
I've tried the code bellow but I get the error TypeError: 'Figure' object is not callable我试过下面的代码,但我得到错误TypeError: 'Figure' object is not callable
ax.figure(num=1, figsize=(6, 4), dpi=150)
Thanks for your help and suggestions!感谢您的帮助和建议!
plt.subplots()
supports all the keyword parameters of plt.figure()
, so to change the resolution, just do: plt.subplots()
支持plt.figure()
() 的所有关键字参数,因此要更改分辨率,只需:
fig, ax = plt.subplots(dpi=150)
Take a look at the docs:看看文档:
EDIT: The reason your code isn't working is because ax.figure
is a Figure object, not a function.编辑:您的代码不起作用的原因是因为
ax.figure
是图 object,而不是 function。 This is why it's "not callable."这就是它“不可调用”的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.