Sep 4, 2013

Saving images of plots made in Matplotlib

Matplotlib, a versatile python library for 2D plotting, allows saving images in several bitmap formats as well as vector formats like SVG.To save an image, one has to specify output format first. Then simply calling a save image function gets the job done. The following example saves an image in SVG format, then in PNG.
from matplotlib import pyplot as plt #code for drawing the plot goes here plt.savefig("output.svg") plt.savefig("output.png")
As you can see, the library figures out the format of output from the extension of the output file name.

No comments:

Post a Comment