1

I'm trying to insert a plot into another one by using:

...
im = plt.imread(get_sample_data('Inset.eps', asfileobj=True),format='eps')
newax = f.add_axes([0.14, 0.30, 0.45, 0.40])
newax.imshow(im,interpolation='none')
newax.axis('off')
plt.savefig('FinalPlot.eps',format='eps',dpi=1000,bbox_inches='tight')

The problem is that everything in FinalPlot.eps has good resolution but the inset, it has a really poor quality. Do you know how to improve the quality of the inset?

Image example

3
  • Do you have access to the 'Inset.eps' data (and code)? Can you save it instead as, say a PNG of very high resolution and then do the same inclusion? I think matplotlib.pyplot.imread uses PIL to read in images, and the rasterization method might play a role (indeed: matplotlib.org/devdocs/api/_as_gen/…). Also, what happens when you save your figure in say .png format, with a high dpi, say 'dpi=150'? Commented Jan 8, 2018 at 12:56
  • Thank you Magnus, seems like it does not like .eps nor ps. I changed the format to .png and it is better now. Commented Jan 9, 2018 at 0:28
  • OK, good. The only downside to this is a (in general) larger file size. Commented Jan 9, 2018 at 8:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.