In JupyterLab, when using the %matplotlib widget backend, the "Download plot" button typically saves the plot as a PNG by default. To save the plot as an SVG instead, you need to configure the matplotlib backend or use a workaround, since the widget backend does not natively support SVG downloads directly from the toolbar.
You can manually save the plot as an SVG using Python code. Here’s how:
%matplotlib widget.fig.savefig():python%matplotlib widget import matplotlib.pyplot as plt # Create your plot fig, ax = plt.subplots() ax.plot([1, 2, 3], [4, 5, 6]) # Save as SVG fig.savefig("plot.svg", format="svg", dpi=1200, bbox_inches="tight")
%matplotlib inline for SVG DownloadsIf you want the "Download plot" button to save as SVG, switch to the %matplotlib inline backend:
python%matplotlib inline import matplotlib.pyplot as plt # Create your plot fig, ax = plt.subplots() ax.plot([1, 2, 3], [4, 5, 6]) # The "Download plot" button will now save as SVG
%matplotlib inline, the "Download plot" button in JupyterLab will save the plot as an SVG by default.%matplotlib widget backend uses a canvas-based renderer, which does not support SVG downloads directly from the toolbar.%matplotlib inline backend renders plots as SVG in the notebook, so the download button works as expected.