To save a matplotlib figure in SVG format by default, you can configure the rcParams (runtime configuration parameters) at the start of your script. This way, every figure you create will be saved in SVG unless you explicitly specify otherwise.
Add this line at the beginning of your script:
pythonimport matplotlib.pyplot as plt plt.rcParams['savefig.format'] = 'svg'
Now, whenever you call plt.savefig("filename"), the figure will be saved in SVG format by default.
If you want to ensure SVG format is used for a specific save, you can also do:
pythonplt.savefig("filename.svg", format="svg")
Which method do you prefer? I can also show you how to combine this with other settings, like DPI or transparent backgrounds, if needed!
Vibe can make mistakes. Check answers. Learn more