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?
show() . If you do not want to use inline plotting, just use %matplotlib instead of %matplotlib inline .
MatPlotLib with PythonJust using the savefig method of the pyplot package and mentioning the file format, we can save the output as a SVG format.
Why matplotlib inline is used. You can use the magic function %matplotlib inline to enable the inline plotting, where the plots/graphs will be displayed just below the cell where your plotting commands are written. It provides interactivity with the backend in the frontends like the jupyter notebook.
So %matplotlib inline is only necessary to register this function so that it displays in the output. Running import matplotlib. pyplot as plt also registers this same function, so as of now it's not necessary to even use %matplotlib inline if you use pyplot or a library that imports pyplot like pandas or seaborn.
%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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With