Re: [Matplotlib-users] PS and imshow

2007-08-31 Thread Petr Danecek
OK, I've got it. Previously, I checked the quality of the output image
by two means: by visual inspection in gv and by checking the size of the
output eps images. 
I was puzzled by the different sizes of the images at magnification 1.
Also, convert produces much larger eps files. 

When the size of the output image is set to 6.3246cm (1494px at 600dpi)
and the axes are turned off, both versions appear identical when
printed. 

Thanks for your help,
petr


On Thu, 2007-08-30 at 20:35, Jouni K. Seppänen wrote:
> I don't see a big difference between test-600.eps and test-convert.eps
> when viewed in gv with magnification 10 and 0.1, respectively. Obviously
> there is some resampling in test-600.eps: your source image is 1494 by
> 1494 pixels large, which at 600 dpi is larger than the 5 by 5 cm figure
> created by the script (and the axes are even smaller). test-convert.eps
> has a bounding box of 0 0 1494 1494, so obviously it is a non-resampled
> image at 72 dpi.
> 
> If the problem you are alluding to is in the resampling, perhaps 
> varying the interpolation algorithm will produce a better result? 
> See the docstring of imshow.
> 
> To get a non-resampled image, figimage should work, but it doesn't seem
> to understand PIL images yet...


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] PS and imshow

2007-08-30 Thread Jouni K . Seppänen
Petr Danecek <[EMAIL PROTECTED]> writes:

> On Fri, 2007-08-24 at 20:03, Jouni K. Seppänen wrote:
>
>> savefig('foo10.ps', dpi=10)
>> savefig('foo100.ps', dpi=100)
>
> In fact, the dpi option does change the resulting PS file, but the
> quality is still very poor - see the example
>   http://www.ucl.cas.cz/~petr/matplotlib-test.tgz

I don't see a big difference between test-600.eps and test-convert.eps
when viewed in gv with magnification 10 and 0.1, respectively. Obviously
there is some resampling in test-600.eps: your source image is 1494 by
1494 pixels large, which at 600 dpi is larger than the 5 by 5 cm figure
created by the script (and the axes are even smaller). test-convert.eps
has a bounding box of 0 0 1494 1494, so obviously it is a non-resampled
image at 72 dpi.

If the problem you are alluding to is in the resampling, perhaps 
varying the interpolation algorithm will produce a better result? 
See the docstring of imshow.

To get a non-resampled image, figimage should work, but it doesn't seem
to understand PIL images yet...

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] PS and imshow

2007-08-29 Thread Petr Danecek

In fact, the dpi option does change the resulting PS file, but the
quality is still very poor - see the example
http://www.ucl.cas.cz/~petr/matplotlib-test.tgz
pd


On Fri, 2007-08-24 at 20:03, Jouni K. Seppänen wrote:

> I just tried with current svn, and the following script produces two
> results that have visibly different resolutions:
> 
> #!/usr/bin/python
> from pylab import *
> foo = rand(10,10)
> imshow(foo)
> savefig('foo10.ps', dpi=10)
> savefig('foo100.ps', dpi=100)
> 
> Perhaps the original poster could show a bit of code where the scaling
> fails?
> 
> (I'm not sure if figimage is doing the right thing, though...)
-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] PS and imshow

2007-08-24 Thread Jouni K . Seppänen
"John Hunter" <[EMAIL PROTECTED]> writes:

> On 8/24/07, Christopher Barker <[EMAIL PROTECTED]> 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. [...]
>
> 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

I just tried with current svn, and the following script produces two
results that have visibly different resolutions:

#!/usr/bin/python
from pylab import *
foo = rand(10,10)
imshow(foo)
savefig('foo10.ps', dpi=10)
savefig('foo100.ps', dpi=100)

Perhaps the original poster could show a bit of code where the scaling
fails?

(I'm not sure if figimage is doing the right thing, though...)

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] PS and imshow

2007-08-24 Thread John Hunter
On 8/24/07, Christopher Barker <[EMAIL PROTECTED]> 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.

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

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] PS and imshow

2007-08-24 Thread Christopher Barker
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
> :-(

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

[EMAIL PROTECTED]

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] PS and imshow

2007-08-24 Thread Petr Danecek
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
:-(

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


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users