How to increase image size in matplotlib and pandas?

18,495

Solution 1

I guess you're using pandas, and you should use:

data_ordertotal.plot(figsize=(40,40))

It doesn't work with plt.figure(figsize=(40,40)) because pandas will create a new figure if you don't pass it an axe object.

It would work with:

fig, ax = plt.subplots(1, 1, figsize=(40,40))
data_ordertotal.plot(ax=ax)

...Assuming you're using pandas, if not you should detail a bit more what is data_ordertotal

HTH

Solution 2

when you create a figure change the figsize. The dimension are in inches

import matplotlib.pyplot as plt

plt.figure(num=1, figsize=(40, 40), dpi=80, facecolor='w', edgecolor='k')

That works for me in spyder.

fig = plt.gcf()
fig.set_size_inches(18.5, 10.5)

should also work

Share:
18,495
Blue Moon
Author by

Blue Moon

Updated on June 25, 2022

Comments

  • Blue Moon
    Blue Moon almost 2 years

    I am trying to increase the size of the image resulting from this function:

    plt.figure()); data_ordertotal.plot(); plt.legend(loc='best')
    

    I tried this but the size remains the same

    plt.figure(figsize=(40,40)); data_ordertotal.plot(); plt.legend(loc='best')
    

    I am coding using spyder and the output in the console remains always the same size. Any solution? Thanks