I am using matplotlib (within pylab) to display figures. And I want to save them in .jpg format. When I simply use the savefig command with jpg extension this returns :
ValueError: Format "jpg" is not supported.
Supported formats: emf, eps, pdf, png, ps, raw, rgba, svg, svgz.
Is there a way to perform this ?
Saving a plot on your disk as an image file Now if you want to save matplotlib figures as image files programmatically, then all you need is matplotlib. pyplot. savefig() function. Simply pass the desired filename (and even location) and the figure will be stored on your disk.
To save a plot or graph or a figure as png we use the savefig() method.
Click the chart that you want to save as a picture. Choose Copy from the ribbon, or press CTRL+C on your keyboard . Switch to the application you want to copy the chart to. If you're saving as a separate image file open your favorite graphics editor, such as Microsoft Paint.
You can save an image as 'png' and use the python imaging library (PIL) to convert this file to 'jpg':
import Image import matplotlib.pyplot as plt plt.plot(range(10)) plt.savefig('testplot.png') Image.open('testplot.png').save('testplot.jpg','JPEG')
The original:
The JPEG image:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With