By default jupyter notebook inline plots are displayed as png, e.g.:
import matplotlib.pyplot as plt
%matplotlib inline
plt.plot()
How can you configure jupyter notebooks to display matplotlib inline plots as svg?
By default jupyter notebook inline plots are displayed as png, e.g.:
import matplotlib.pyplot as plt
%matplotlib inline
plt.plot()
How can you configure jupyter notebooks to display matplotlib inline plots as svg?
set_matplotlib_formats()
is deprecated since May 2021.
DeprecationWarning:
set_matplotlib_formats
is deprecated since IPython 7.23, directly usematplotlib_inline.backend_inline.set_matplotlib_formats()
set_matplotlib_formats('svg')
Current Working method:
%matplotlib inline
import matplotlib_inline
matplotlib_inline.backend_inline.set_matplotlib_formats('svg')
%config InlineBackend.figure_formats = ['svg']
does the trick. A minimal example is:
%config InlineBackend.figure_formats = ['svg']
import matplotlib.pyplot as plt
%matplotlib inline
plt.plot()
InlineBackend.figure_format
is deprecated on IPython 2.0.0, use set_matplotlib_formats
instead. –
Inamorato InlineBackend.figure_format
is deprecated in favor of InlineBackend.figure_formats
(note the extra 's' at the end), which supports specifying multiple formats. Other than this, the usage through %config
is not deprecated. –
Shaduf set_matplotlib_formats()
can set the image formats and other options such as quality at the same time. –
Inamorato Use set_matplotlib_formats('svg')
.
import matplotlib.pyplot as plt
from IPython.display import set_matplotlib_formats
%matplotlib inline
set_matplotlib_formats('svg')
plt.plot()
This is also documented in a document of %matplotlib magic.
Note: InlineBackend.figure_format
is deprecated.
set_matplotlib_formats
is deprecated since IPython 7.23, directly use matplotlib_inline.backend_inline.set_matplotlib_formats()
after removing the cwd from sys.path. –
Brass set_matplotlib_formats()
is deprecated since May 2021.
DeprecationWarning:
set_matplotlib_formats
is deprecated since IPython 7.23, directly usematplotlib_inline.backend_inline.set_matplotlib_formats()
set_matplotlib_formats('svg')
Current Working method:
%matplotlib inline
import matplotlib_inline
matplotlib_inline.backend_inline.set_matplotlib_formats('svg')
In 2024, the method that is not deprecated is:
%config InlineBackend.figure_formats = ['svg']
Add this to the notebook cell, and all output will be in .svg
format.
© 2022 - 2025 — McMap. All rights reserved.
%matplotlib notebook
? I can't seem to find a way to make the figure display as svg quality – Gardol