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