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.

Supported Backends:

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

Partially supported backends:

VS code may sometimes work with these options (has worked in some environments, but not others):

  • %matplotlib qt5
  • %matplotlib agg

Unsupported backends (has been tried and fails/hangs):

  • %matplotlib tk
  • %matplotlib notebook
  • %matplotlib nbagg
  • %matplotlib wx
  • %matplotlib svg
  • %matplotlib pdf
Clone this wiki locally