Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jupyter notebook 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?

like image 892
Fabian Rost Avatar asked Apr 14 '16 11:04

Fabian Rost


People also ask

What can I use instead of %Matplotlib inline?

show() . If you do not want to use inline plotting, just use %matplotlib instead of %matplotlib inline .

Can matplotlib save as SVG?

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 is %Matplotlib inline?

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.

Do We Still Need %Matplotlib inline?

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.


1 Answers

%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() 
like image 167
Fabian Rost Avatar answered Sep 21 '22 17:09

Fabian Rost