How to Export Your Plots
00:00 In this final lesson before the summary, I want to show you how you can export some of the graphs that you’ve created and save them as separate files. You head back over to your Notebook.
00:11 Let’s say you want to export this graph that you created just here. You could go ahead and instead of printing it out, as you did until now, you want to assign it to a variable.
00:21
So we’re going to say, this is the plot, and you assign it to this plot
variable, and then you can call the .save()
method on it. Each plot object has this .save()
method, and then you just need to pass it a name.
00:36
This could be "classes_xkcd.png"
. Then, optionally, you can also pass dpi
(dots per inch), so you can tell it how big and what good quality you want the plot to be. And if you run this, you don’t see any output here. There’s a couple of warnings.
00:54 But if you head over to your file system,
00:58 then you can see that there’s a new file that popped up with the name that you just gave it. If you open this, you can see it’s a PNG file that contains just the graph that you created.
01:10 And this is how you export your plots and save them as separate files with plotnine. In the next lesson, which is going to be the final lesson of the course, you’re going to quickly go over all the topics that you covered in this course and just have a quick summary and recap and close out the course. See you there!
Become a Member to join the conversation.