Sachin Kumar
Sachin Kumar

Reputation: 957

fig.set_figheight and fig.set_figwidth not working

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)

[This is what I am getting][enter image description here]1

Is there a way to make them bigger?

Upvotes: 0

Views: 884

Answers (1)

ImportanceOfBeingErnest
ImportanceOfBeingErnest

Reputation: 339220

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)

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.

Upvotes: 1

Related Questions