jupyter notebook inline plots as svg

时间:2016-04-14 11:52:09

标签: svg matplotlib jupyter-notebook

默认情况下,jupyter笔记本内联图显示为png,例如:

import matplotlib.pyplot as plt
%matplotlib inline
plt.plot()

如何配置jupyter笔记本以将matplotlib内联图显示为svg?

2 个答案:

答案 0 :(得分:39)

%config InlineBackend.figure_formats = ['svg']可以解决问题。一个最小的例子是:

%config InlineBackend.figure_formats = ['svg']

import matplotlib.pyplot as plt
%matplotlib inline
plt.plot()

答案 1 :(得分:7)

使用set_matplotlib_formats('svg')

import matplotlib.pyplot as plt
from IPython.display import set_matplotlib_formats
%matplotlib inline
set_matplotlib_formats('svg')
plt.plot()

这也记录在a document of %matplotlib magic中。

注意:InlineBackend.figure_formatdeprecated