Skip to content

Instantly share code, notes, and snippets.

@cjbayesian
Last active May 18, 2017 14:55
Show Gist options
  • Save cjbayesian/cebdabc8a5ba973ea3359da412ab26be to your computer and use it in GitHub Desktop.
Save cjbayesian/cebdabc8a5ba973ea3359da412ab26be to your computer and use it in GitHub Desktop.

Create arbitrarily high resolution figures using matplotlib

In python, create your figure and save it as .eps. This will generate a vector image of your figure:

fig, ax = plt.subplots()
ax.plot(range(10))
fig.savefig('straightLine.eps', format='eps')

Using ghostscript and ImageMagick, convert to .jpg, defining the resolution using the -density flag.

epstopdf straightLine.eps
convert -density 1200 -trim straightLine.pdf -quality 100 straightLine.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment