uwhpsc-2016 / homework1

Homework #1
1 stars 1 forks source link

Saving Matplotlib plots as .jpg or .png files #39

Open rachka opened 8 years ago

rachka commented 8 years ago

When we are going about doing our reports, what is the best way to extract the plots from SMC? I have tried saving plots as .jpeg or .png files but this only generates completely white images. Am I going about this the wrong way?

afarahatoutset commented 8 years ago

I would save them as vector graphics (e.g. .eps or .svg) not to lose resolution. matplotlib.pyplot.savefig really helps with that. I assume this function can save your figure in whatever format you want.

cswiercz commented 8 years ago

Example:

import matplotlib.pyplot as plt

plt.[etc]   # do some plotting stuff

plt.savefig(...)

take a look at the documentation for plt.savefig() for details.

cswiercz commented 8 years ago

See Issue #33

rachka commented 8 years ago

It turns out that I placed plt.show() before plt.savefig() which caused a blank figure to be saved. Thanks.