Skip to content

Using %matplotlib widget instead of %matplotlib notebook,tk,etc

Rich Chiodo edited this page Dec 6, 2021 · 9 revisions

Matplotlib supports specifying a backend for rendering matplotlib graphs through the use a %matplotlib <backend> line magic. Most of these implementations will shell out to an interactive window when plotting.

Some of the backend options do not work always work well in VS code.

VS code should work with these two options (has been thoroughly tested):

  • %matplotlib inline - This is the default and will render images as PNGs
  • %matplotlib widget - This generates an ipywidget that renders plots in a control. Multiple plots and zooming are supported. For more information see the README

VS code may sometimes work with these options (has been tried at least once):

  • %matplotlib qt5

VS code hangs with these options:

  • %matplotlib tk

VS code does nothing with these options:

  • %matplotlib notebook
Clone this wiki locally