Closed
Description
I'm trying to adapt http://matplotlib.org/mpl_toolkits/axes_grid/users/overview.html#imagegrid to get a plot of two square images side-by-side and a colorbar on the right with their (shared) scale. The images are log-scaled for display by passing norm=LogNorm()
to the imshow()
call. It looks like the presence of LogNorm is somehow breaking the display with the exception AttributeError: 'XAxis' object has no attribute 'set_scale'
.
To narrow down the issue, I made a copy of the demo script http://matplotlib.org/mpl_toolkits/axes_grid/examples/demo_axes_grid.py
Here it is: https://gist.github.com/josePhoenix/2b9334bd38244b67a893
When I call demo_grid_with_single_cbar_log
, I get the following traceback:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-154-e7efbe23b2be> in <module>()
68
69 fig = plt.figure()
---> 70 demo_grid_with_single_cbar_log(fig)
<ipython-input-154-e7efbe23b2be> in demo_grid_with_single_cbar_log(fig)
54 im = grid[i].imshow(Z, extent=extent, interpolation="nearest", norm=LogNorm()) # modified to log-scale display
55 #plt.colorbar(im, cax = grid.cbar_axes[0])
---> 56 grid.cbar_axes[0].colorbar(im)
57
58 for cax in grid.cbar_axes:
/Users/jlong/homebrew/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpl_toolkits/axes_grid1/axes_grid.py in colorbar(self, mappable, **kwargs)
96 orientation = "vertical"
97
---> 98 cb = Colorbar(self, mappable, orientation=orientation, **kwargs)
99 self._config_axes()
100
/Users/jlong/homebrew/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpl_toolkits/axes_grid1/colorbar.py in __init__(self, ax, mappable, **kw)
730 self.add_lines(CS)
731 else:
--> 732 ColorbarBase.__init__(self, ax, **kw)
733
734
/Users/jlong/homebrew/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpl_toolkits/axes_grid1/colorbar.py in __init__(self, ax, cmap, norm, alpha, values, boundaries, orientation, extend, spacing, ticks, format, drawedges, filled)
375 if isinstance(self.norm, colors.LogNorm):
376 # change both axis for proper aspect
--> 377 self.ax.xaxis.set_scale("log")
378 self.ax.yaxis.set_scale("log")
379 self.ax._update_transScale()
AttributeError: 'XAxis' object has no attribute 'set_scale'