Python Data Visualization Transcripts
Chapter: Matplotlib
Lecture: Saving images

Login or purchase this course to watch this video and the rest of the course contents.
0:00 One area where matplotlib really shines is the ability to save images in multiple
0:07 different formats and we can use the figure that we just created to save our image.
0:16 Earlier we defined an image directory and when we save it we can pass several
0:21 parameters to it. And this will save a PNG image with a transparent background, the DPI of 80 and the B box inches tight.
0:33 Just make sure that the figure fits within the size that saves it. So it kind of compresses the boundaries a little bit.
0:43 If you want to save the image in a different format, maybe we want to save this as an svg image without a transparent background and higher
0:54 DPI can do that as well. Another common one might be a jpg and we can even do a pdf if we
1:06 wanted to. If you ever want to see all the options that you can save there's a little handy tip and you can see on my system,
1:19 I have all the components in place. That I could save any one of these files so you can play around with it
1:25 and find out what works best for you based on your use case for saving the actual images. And if we look, I've opened up in file Explorer,
1:36 the images subdirectory and you can see the different files including a pdf, a .png, .svg file that it wants to open a Microsoft edge and a jpeg file


Talk Python's Mastodon Michael Kennedy's Mastodon