imshow with pdf

I have raised two issues on imshow with pdf backend weeks ago since the upgrade from 0.91 to 0.98. I am happy to see one of them already fixed.

However, the following issue is still there. In the following script, I try to display an image in a pdf. This would run. Now please change the maize.pdf to maize.png and generate yet another file. Zoom and look closely at the two files generated. You see that the pdf quality is substantially lower than the png.

I wonder if anyone would reproduce it and … any way to solve it.

···

from matplotlib.pyplot import *
from urllib import urlretrieve

figure(1,(6,6))
root = axes([0,0,1,1])

urlretrieve(“http://www.alexandrajones.co.uk/images/large/maize.jpg”,“maize_raw.jpg”)
img = imread(“maize_raw.jpg”)
root.imshow(img)

root.set_axis_off()
savefig(“maize.pdf”)

Keep in mind that we can't control the kind of interpolation used by the PDF viewer. I don't know if that is what you're seeing.

I'm not seeing a loss in quality in PDF. I do, however, see a different color profile being applied by acroread (making the corn husk appear darker). matplotlib is completely ignorant of any sort of icc profiles etc., so it's possible it's doing the wrong thing in that regard. It also could be that acroread is one of the few applications on my Linux box that cares about color profiles at all, and it is "right" when everything else is "wrong".

Is the difference seen in my attached screenshot what you're referring to, or are you seeing something worse? What pdf viewer are you using? Are you using the Cairo backend?

Mike

Haibao Tang wrote:

···

I have raised two issues on imshow with pdf backend weeks ago since the upgrade from 0.91 to 0.98. I am happy to see one of them already fixed.

However, the following issue is still there. In the following script, I try to display an image in a pdf. This would run. Now please change the maize.pdf to maize.png and generate yet another file. Zoom and look closely at the two files generated. You see that the pdf quality is substantially lower than the png.

I wonder if anyone would reproduce it and ... any way to solve it.

-----------------------------------------------------------
from matplotlib.pyplot import *
from urllib import urlretrieve

figure(1,(6,6))
root = axes([0,0,1,1])

urlretrieve("http://www.alexandrajones.co.uk/images/large/maize.jpg","maize\_raw\.jpg"\)
img = imread("maize_raw.jpg")
root.imshow(img)

root.set_axis_off()
savefig("maize.pdf")
------------------------------------------------------------------------

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Mike,
Thanks. I use acroread on windows, I am not using Cairo. I see similar thing (my screenshot is attached). Notice that the individual pixels in acroread is larger than it should be?
I understand there are rendering differences (e.g. acroread vs xpdf). But I do not see the same problem if I use 0.91.4, and this is why I wish to find out what has changed.

btw, if you turn on the ‘extent’ to shrink the image, it is even worse. try the following script. I am troubled now because if the same script used to give me good quality. Maybe it only affects acroread on windows?

···

from matplotlib.pyplot import *
from urllib import urlretrieve

figure(1,(6,6))
root = axes([0,0,1,1])

urlretrieve(“http://www.alexandrajones.co.uk/images/large/maize.jpg”,“maize_raw.jpg”)
img = imread(“maize_raw.jpg”)
root.imshow(img,origin=“lower”,extent=(.4,.6,.3,.7))

root.set_axis_off()
root.set_xlim([0,1])
root.set_ylim([0,1])
savefig(“maize.pdf”)

On Mon, Dec 15, 2008 at 11:31 AM, Michael Droettboom <mdroe@…86…> wrote:

Keep in mind that we can’t control the kind of interpolation used by the PDF viewer. I don’t know if that is what you’re seeing.

I’m not seeing a loss in quality in PDF. I do, however, see a different color profile being applied by acroread (making the corn husk appear darker). matplotlib is completely ignorant of any sort of icc profiles etc., so it’s possible it’s doing the wrong thing in that regard. It also could be that acroread is one of the few applications on my Linux box that cares about color profiles at all, and it is “right” when everything else is “wrong”.

Is the difference seen in my attached screenshot what you’re referring to, or are you seeing something worse? What pdf viewer are you using? Are you using the Cairo backend?

Mike

Haibao Tang wrote:

I have raised two issues on imshow with pdf backend weeks ago since the upgrade from 0.91 to 0.98. I am happy to see one of them already fixed.

However, the following issue is still there. In the following script, I try to display an image in a pdf. This would run. Now please change the maize.pdf to maize.png and generate yet another file. Zoom and look closely at the two files generated. You see that the pdf quality is substantially lower than the png.

I wonder if anyone would reproduce it and … any way to solve it.


from matplotlib.pyplot import *

from urllib import urlretrieve

figure(1,(6,6))

root = axes([0,0,1,1])

urlretrieve(“http://www.alexandrajones.co.uk/images/large/maize.jpg”,“maize_raw.jpg”)

img = imread(“maize_raw.jpg”)

root.imshow(img)

root.set_axis_off()

savefig(“maize.pdf”)



SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.

The future of the web can’t happen without you. Join us at MIX09 to help

pave the way to the Next Web now. Learn more and register at

http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/



Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Michael Droettboom

Science Software Branch

Operations and Engineering Division

Space Telescope Science Institute

Operated by AURA for NASA