- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Exporting an svg file from a Matplotlib figure
To export an SVG file from a matplotlib figure, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Create a figure and a set of subplots.
Create random x and y data points using numpy.
Plot x and y data points using plot() method.
Save the .svg format file using savefig() method.
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax = plt.subplots() x = np.random.rand(10) y = np.random.rand(10) ax.plot(x, y, ls='dotted', linewidth=2, color='red') plt.savefig("myimg.svg")
When we execute this code, it will create an SVG file called "myimg.svg" and save it in the current directory.
- Related Articles
- Save figure as file from iPython notebook using Matplotlib
- Drawing an SVG file on an HTML5 canvas
- How to draw an SVG file on an HTML5 canvas?
- Importing / Exporting CSV file in PowerShell
- How can I get the output of a Matplotlib plot as an SVG?
- Exporting data from SAP system to an Excel Report
- Plot data from a .txt file using matplotlib
- How to retrieve XY data from a Matplotlib figure?
- Make a multiline plot from .CSV file in matplotlib
- Plot data from CSV file with Matplotlib
- What kind of settings can we do to a CSV file by query while exporting the values from MySQL table into a CSV file?
- What kind of settings can we do to a text file by query while exporting the values from MySQL table into a text file?
- Exporting list of all SAP HANA systems in XML file
- How can I dynamically update my Matplotlib figure as the data file changes?