0

I am new to Jupyter Notebooks and using Matplotlib for charting but my charts are only filing half of the output cell. I would expect my charts to fill the entire output.

enter image description here

Jon Rose
  • 1,457
  • 1
  • 15
  • 25

1 Answers1

1

You may measure how large in pixels you want your output to be. Divide this number by 72 (which is the default dpi for figures in the notebooks with inline backend). Then set your figure width to this number.

E.g. if you want an 800 pixel wide figure,

fig, axes = plt.subplots(figsize=(800/72., 4.8))

You may also set the default figure size per notebook via

plt.rcParams["figure.figsize"] = (800/72., 4.8)

Or even change the default configuration as shown in this answer.

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
  • This pretty much does it. I'm having to use 1150 rather then 800 though to fill the output cell. Is there are way to get that width value rather then hard code it? Thanks! – Jon Rose Aug 12 '18 at 23:29
  • 2
    Theoretically yes. You can load the css used by jupyter obtain all the relevant values of widths, margins, borders and padding and calculate from them how large the output cell size is. Since some of those are also relative values, you would also need to obtain the browser window size. This is hard to obtain via python, so the latest at this point I would give up and say, practically no. – ImportanceOfBeingErnest Aug 12 '18 at 23:46