Hi all,

I've come across an apparent bug in imshow when outputting to PDF and
EPS files.  (I haven't tested other vector formats.)  It manifests as
a small scaling error between the raster image and the axes
coordinates.

I have attached a test script to illustrate the problem.  The
(correct) PNG output file shows a green 'X' at the common point
between four pixels near the center of the raster image.  The extent
is chosen such that the coordinates refer to pixel centers.  The PDF
and EPS output files show a misalignment between the X and the pixel
boundaries -- zoom in to see it clearly.  Also, the topmost row and
rightmost column appear truncated.

I did some digging to see if I could figure out how the image scale
was being mangled.  I had a hunch that it was due to some interaction
between fixed-72-dpi code, rounding the number of pixels, and
subsequent rescaling.  However, the image scale still seems to be off
even when the dpi setting is a multiple of 72.

I am using svn r7395 on OSX 10.4.11.  I previously posted to the
matplotlib-devel list, but perhaps the larger audience here can help.
Can anyone confirm this bug?  I have added it to the sourceforge
tracker, ID 2832896.
https://sourceforge.net/tracker/?func=detail&aid=2832896&group_id=80706&atid=560720

Thank you for the attention,
Mike
import numpy as n
import matplotlib as mpl
import pylab

ny, nx = 50, 50
im = n.arange(ny*nx) % 3
im.shape = (ny, nx)

extent = (-0.5, nx-0.5, -0.5, ny-0.5)

fig = pylab.figure(0, figsize=(5,5))
fig.clear()
fig.hold(True)
ax = fig.add_subplot(111)

ax.imshow(im, extent=extent,
          interpolation='nearest',
          cmap=mpl.cm.gray_r,
          origin='lower',
          vmax=3.)
ax.set_autoscale_on(False)
ax.plot(((nx-1)/2.,), ((ny-1)/2.,), '+', c='g', ms=4, mew=1.)

pylab.draw()
#pylab.show()
dpi = 300
pylab.savefig('test.png', dpi=dpi)
pylab.savefig('test.pdf', dpi=dpi)
pylab.savefig('test.eps', dpi=dpi)
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to