jupyter notebook inline plots as svg

不想你离开。 提交于 2019-12-20 08:38:15

问题


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?


回答1:


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.




回答2:


%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()


来源:https://stackoverflow.com/questions/36622237/jupyter-notebook-inline-plots-as-svg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!