[Matplotlib-users] odd ticking in ImageGrid

Slavin, Jonathan jslavin at cfa.harvard.edu
Wed Jan 25 14:06:09 EST 2017


Hi,

Since upgrading to matplotlib 2.0.0 I've found that one of the plots I made
before has odd behavior in ticking.  Sample code to reproduce the problem
is as follows:

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LogNorm,Normalize
from mpl_toolkits.axes_grid1 import ImageGrid

fig = plt.figure()
grid = ImageGrid(fig, 111, nrows_ncols = (2,2), share_all =
        True, add_all=True, label_mode = 'L', cbar_mode = 'single')

for g in grid:
    image = (10.**(3.*np.random.rand(100))).reshape((10,10))
    im = g.imshow(image, origin='lower', norm=LogNorm(),
            interpolation='none', extent=(0., 29.9, 0., 29.9),
            cmap='viridis', vmin=1.,vmax=1.E3)

grid.cbar_axes[0].colorbar(im)
grid.cbar_axes[0].set_yticks([1.,10.,100.,1.E3])
grid.cbar_axes[0].set_yticklabels([r'$1.0$', r'$10$',r'$10^{2}$',
r'$10^{3}$'])

plt.show()

​The result I get is shown in the attached image.  The issue is the "2 x
10^0" in the lower right. It seems that it's associated with the colorbar,
but doing things like grid.cbar_axes[0].set_xticks([]) has no effect.  If I
don't include the colorbar that annotation doesn't get created.  It also
seems to be associated with using norm=LogNorm().  In fact if I don't
include setting the yticks and yticklabels on the colorbar, I get that "2
x10^0" label and "None" at the upper right.  So, this certainly seems like
some sort of bug.  It doesn't to that using version 1.5.  I can submit a
bug report if desired.

Jon​

-- 
________________________________________________________
Jonathan D. Slavin                 Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu       60 Garden Street, MS 83
phone: (617) 496-7981       Cambridge, MA 02138-1516
cell: (781) 363-0035             USA
________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170125/22878c4b/attachment.html>


More information about the Matplotlib-users mailing list