fig.set_figheight 和 fig.set_figwidth 不工作 [英] fig.set_figheight and fig.set_figwidth not working

查看:36
本文介绍了fig.set_figheight 和 fig.set_figwidth 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么这段代码没有改变绘制图形的大小?

Why is this code not changing the size of the figure plotted?

   fig1, ax1 = plt.subplots(nrows=1, ncols=3)
   fig1.set_figheight = 30
   fig1.set_figwidth = 30
   x = np.array([1,2,3,4,5])
   for i in range(3):
       ax1[i].plot(x, x**i)

[这就是我得到的][]1

[This is what I am getting][]1

有没有办法让它们变大?

Is there a way to make them bigger?

推荐答案

fig1.set_figheight = 3030 分配给 .set_figheight 属性.虽然以前的 fig1.set_figheight 是一种可以用来更改图形高度的方法,但是从现在开始,它只是 30 .

fig1.set_figheight = 30 assigns 30 to the .set_figheight attribute. While previously fig1.set_figheight was a method that could be used to change the height of the figure, from now on it is, well, simply 30.

解决方案很简单:使用方法代替销毁它.

The solution is simple: Use the method instead of destroying it.

fig1.set_figheight(30)

请注意,由于您已经覆盖了该方法,因此您需要重新启动内核,以便可以重新导入 matplotlib 并将属性恢复到其原始状态.

Note that because you have overwritten the method you will need to restart the kernel, such that matplotlib can be reimported and the attribute is restored to its original state.

这篇关于fig.set_figheight 和 fig.set_figwidth 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆