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 am using svn r7395.

Thanks 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,
          origin='lower')
ax.set_autoscale_on(False)
ax.plot(((nx-1)/2.,), ((ny-1)/2.,), 'x', c='g', ms=4, mew=1.25)

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-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to