PS and imshow

Hi,
I'd like to open a high-quality image (600dpi) in matplotlib, add some
plots and save it as a postscript file.
It seems that whatever I do, the input image gets scaled down
:frowning:

The same question was asked year ago. Has any progress been made since
then?
http://sourceforge.net/mailarchive/message.php?msg_id=200608311227.30594.dd55%40cornell.edu

Looking in the code of matplotlib, there is a constant of 72dpi
hardwired everywhere. For instance, backend_ps.py there is the line
聽聽self.figure.dpi.set(72) # ignore the dpi kwarg
Would rising of this value to 600 help?

No offence to developers, I did not even try to understand the code, but
using the number 72 instead of using a variable seems to be a bad
programming practice to me.
Petr Danecek

Petr Danecek wrote:

Hi,
I'd like to open a high-quality image (600dpi) in matplotlib, add some
plots and save it as a postscript file. It seems that whatever I do, the input image gets scaled down
:frowning:

I'm sorry I don't know enough about MPL's handling of images to help, but...

Looking in the code of matplotlib, there is a constant of 72dpi
hardwired everywhere. For instance, backend_ps.py there is the line
聽聽self.figure.dpi.set(72) # ignore the dpi kwarg

This may not be what it seems. The native coordinate system for PostScript is in points, which are 1/72 if an inch, so it's common to force that as a dpi. Postscript supports fractional (is it floating point or fixed -- I'm not sure) points, however, so you can define things in higher resolution, and I'm pretty sure you can imbed an arbitrary dpi image in a a PostScript file, using the 72dpi to positions the image.

The problem comes if the code, in addition to using 72dpi, also assumes integer coordinates, then you can't get better accuracy that 72dpi, which is not very good, and is really bad if someone scales it up later. wxWidgets addresses this by hard-coding 720dpi, rather than 72, and dividing by ten when writing the postscript -- still a bit of kludge. I'm not sure what MPL does.

-Chris

路路路

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

Yes, this is exactly right and the reason we do it this way. We
support fractional points so indeed you have higher resolutions. Off
the top of my head, I am not sure what is going on with the image
resolution problem....

JDH

路路路

On 8/24/07, Christopher Barker <Chris.Barker@...259...> wrote:

This may not be what it seems. The native coordinate system for
PostScript is in points, which are 1/72 if an inch, so it's common to
force that as a dpi. Postscript supports fractional (is it floating
point or fixed -- I'm not sure) points, however, so you can define
things in higher resolution, and I'm pretty sure you can imbed an
arbitrary dpi image in a a PostScript file, using the 72dpi to positions
the image.