Figure is stretched to window size
See original GitHub issueJupyterlab 1.0 and ipympl 0.3.1
Regardless of what figsize is set to, the plot appears stretched, see screenshot.

Temporary workaround:
If you want the “traditional” fixed size figure, you can use the following figure() function instead of plt.figure():
https://gist.github.com/thomasaarholt/9841ce2424bc40e3165142764e960150
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:38 (25 by maintainers)
Top Results From Across the Web
How can you change how a matplotlib figure/axes is stretched ...
But, when you resize the window, the figure stretches in such a way that there is a large empty space created on the...
Read more >How to make figure window change size - MATLAB Answers
The figure window stopped responding to commands. The figure window size does not change when I try to resize it using set(gcf, [...
Read more >Autocad - Stretch command (change window size - Fast tutorial!)
This video explains how to stretch and shrink figures. We use for that the command STRETCH in the section modify.
Read more >How to fix a stretched/squished screen/desktop (Resolution)
Hello YouTube!Today Im going to show you how to fix your stretch /squished screen /desktop. (other words: Resolution )There are 2 ways to...
Read more >Change the size of a picture, shape, text box, or WordArt
If you want to stretch, shrink, or just change the size of a picture (or shape), use the sizing handles or for more...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Jupyter newcomer here, my unsolicited opinion:
I don’t really mind that the figure adjusts to the width of the notebook window. In data analysis, the more screen space one can give the visualization, the better.
I do however mind that the aspect ratio becomes weird. I would posit that the classic figure aspect ratio is 4:3, going up to 2:1 may make sense, but beyond that it becomes silly (except for special situations).
Is it possible to fix the aspect ratio, so as the figure becomes wider, it also becomes higher?
Or, assuming that the notebook window width corresponds to about 80 em, set the figure height to 60 em?
As I said, newbie here, so maybe what I’m saying doesn’t make sense: But why can’t the matplotlib figsize simply be used in the notebook? As I understand, it’s in inches, converted to pixels through a dpi value, and an html element size can also be specified in inches.
About the current situation
figure.canvasis an instance ofDOMWidget. Sizing and layout of DOMWidget are set by theirlayoutattribute, which allow setting any CSS property impacting layout to the top-level DOM element.figsizeis not the thing setting the layout. Maybe a means to fix this would be to have figsize actually be tied to layout in the case of ipympl somehow.Now, in order for matplotlib to behave consistently with Jupyter widgets and respect the matplotlib API, we need to align fiction to reality, in one direction or the other.
ipywidgets.Layoutfor the case of the matplotlib figure for it to only accept sizes in inches so that it makes sense for thefigsizeapi. In that case, we could easily bind figsize to the layout attribute. A drawback of this approach is that laying out and aligning figures with other jupyter widgets may be very difficult or impossible since the correspondance between inches and other size units depends on the client - and a notebook that works well for one user may look completely different for another.Thoughts?