Matplotlib
keyboard_arrow_down 83 guides
chevron_leftSaving Cookbook
check_circle
Mark as learned thumb_up
0
thumb_down
0
chat_bubble_outline
0
Comment auto_stories Bi-column layout
settings
Saving a graph in Matplotlib
schedule Aug 10, 2023
Last updated local_offer
Tags Python●Matplotlib
tocTable of Contents
expand_more Master the mathematics behind data science with 100+ top-tier guides
Start your free 7-days trial now!
Start your free 7-days trial now!
Saving as png
To save a graph in Matplotlib as a png
, use the following:
plt.plot([1,2]) # Your graphplt.savefig("my_curve.png")
This will save a file named "my_curve.png" in the same directory as your Python script.
Saving as svg
To save a graph in Matplotlib as a svg
, use the following:
plt.plot([1,2]) # Your graphplt.savefig("my_curve.svg")
This will save a file named "my_curve.svg" in the same directory as your Python script.
Saving as pdf
To save a graph in Matplotlib as a pdf
, use the following:
plt.plot([1,2]) # Your graphplt.savefig("my_curve.pdf")
This will save a file named "my_curve.pdf" in the same directory as your Python script.
Specifying resolution
To specify the resolution, pass the dpi
argument:
plt.plot([1,2]) # Your graphplt.savefig("my_curve.png", dpi = 300)
NOTE
dpi
stands for "dots per inch". The larger the value passed, the higher the resulting resolution.
Published by Isshin Inada
Edited by 0 others
Did you find this page useful?
thumb_up
thumb_down
Comment
Citation
Ask a question or leave a feedback...
thumb_up
0
thumb_down
0
chat_bubble_outline
0
settings
Enjoy our search
Hit / to insta-search docs and recipes!