How to make matplotlibs nbagg backend generate SVGs?

爱⌒轻易说出口 提交于 2019-12-13 02:37:40

问题


Currently, I'm using the following at the start of my notebook to generate SVG plots:

%matplotlib inline
%config InlineBackend.figure_format = 'svg'

When using the nbagg backend instead (like this: %matplotlib nbagg), plots are generated as PNGs. Is it possible to configure the nbagg backend to generate SVGs?


回答1:


The Agg backend in matplotlib uses the Anti-Grain Geometry 2D graphics library to generate bitmap graphics. The documentation for the backend states:

Output to RGBA and PNG, optionally JPEG and TIFF

The NbAgg backend wraps the Agg backend (via WebAgg core) and so is also limited to those output types.

Note that this simply defines the backend used to generate figures for viewing. Regardless of backend, you can still save figures to SVG format using figure.savefig('<filename'> format='svg') (or using a filename ending in .svg).



来源:https://stackoverflow.com/questions/37594446/how-to-make-matplotlibs-nbagg-backend-generate-svgs

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