Yep, I can confirm this but the story is a bit different on my side since the
.png is wrong but not the .pdf (only ok with Acrobat Reader though):
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
n = 16
fig = plt.figure(figsize=(6,6))
Z = np.zeros((n,n))
Z[::2,::2] = Z[1::2,1::2] = 1
plt.imshow(Z, interpolation='none', cmap=plt.cm.gray, extent=[0,n,0,n],
alpha=0.25)
plt.xticks(np.arange(0,n), []), plt.yticks(np.arange(0,n), [])
plt.grid(ls='solid')
delta = 0.01
plt.xlim(1-delta,1+delta), plt.ylim(1-delta,1+delta)
plt.savefig('pylab-grid.png')
plt.savefig('pylab-grid.pdf')
Nicolas
On Oct 30, 2012, at 10:59 , Maciek Dems wrote:
> In reply to message from Nicolas Rougier, dated Tuesday 30 of October 2012,
> on subject "Re: [matplotlib-devel] Misalignment imshow vs. grid lines"
> > You're right. Using 'none' interpolation seems to solve the problem. Good
> > to know !
>
> Unfortunately it does not! It only makes problem less pronounced, but still
> present. Furthermore pcolor is also affected, similarly to imshow, however,
> the misalignment is usually no more than one pixel (although in some
> applications it is still unacceptable).
>
> I guess that the problem is with truncation errors in some calculations...
>
> Here are some test scripts and sample results. Mind that the misalignment
> depend randomly on zoom factor and the position of the image.
>
> The scripts:
>
> # test_imshow.py
> # --------------
> import numpy as np
> import matplotlib.pyplot as plt
>
> n = 16
> fig = plt.figure(figsize=(10,10))
>
> Z = np.ones((n, n))
> Z[::2, ::2] = 2
> Z[1::2, 1::2] = 2
>
> def test(interp, sub):
> plt.subplot(sub)
>
> plt.imshow(Z, interpolation=interp,
> cmap='gray', extent=[0, n, 0, n], vmin=0)
>
> plt.xticks(np.arange(n))
> plt.yticks(np.arange(n))
> plt.grid(ls='solid')
> plt.title(interp)
>
> test('nearest', 121)
> test('none', 122)
>
> plt.show()
>
>
>
> # test_pcolor.py
> # --------------
> import numpy as np
> import matplotlib.pyplot as plt
>
> n = 16
> fig = plt.figure(figsize=(10,10))
>
> Z = np.ones((n, n))
> Z[::2, ::2] = 2
> Z[1::2, 1::2] = 2
>
> plt.pcolor(np.arange(n+1), np.arange(n+1), Z,
> cmap='gray', vmin=0)
>
> plt.xticks(np.arange(n))
> plt.yticks(np.arange(n))
> plt.grid(ls='solid')
>
> plt.show()
>
>
>
> The results (some manual zooming) are attached and also available here:
> http://dems.art.pl/files/imshow.png
> http://dems.art.pl/files/pcolor.png
>
> --
> Maciek Dems http://dems.art.pl/en
> <pcolor.png><imshow.png>------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct_______________________________________________
> Matplotlib-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel