Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd tick setting and labeling in axes_grid1.ImageGrid #7948

Open
jslavin opened this issue Jan 25, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@jslavin
Copy link

commented Jan 25, 2017

To help us understand and resolve your issue, please fill out the form to the best of your ability. You can feel free to delete the sections that do not apply.

Bug report

Bug summary

The colorbar in an axes_grid1.ImageGrid gets a labeled xtick (for a vertically oriented colorbar). The ylabels are also oddly labeled. Also for a 2 x 2 grid, the xaxis ticks and yaxis ticks are not the same despite the extent being set to the same values.

Code for reproduction

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, 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)
plt.show()

Actual outcome

See the image. colorbar labeling is messed up. In other cases the xtick labeling is different (different number of ticks) than the ytick labeling despite having the same extent.

Expected outcome

The labeling of the colorbar should something like (10^-1 10^0, ...etc.). This used to work with matplotlib 1.5.X (last one)

Matplotlib version

Matplotlib version 2.0.0, CentOS Linux 6 or Mac OSX 10.12.2

prob_demo2
installed Matplotlib via conda

@efiring

This comment has been minimized.

Copy link
Member

commented Jan 25, 2017

Part of the problem is that axes_grid1 has its own colorbar, which seems to be a modified version of an old version of the normal colorbar. I am not aware of any documentation as to why and how it differs. As a result, improvements in the normal colorbar (of which some were made in 2.0, and more are needed) do not appear in the axes_grid1 colorbar. I think we need to figure out how to completely replace the present axes_grid1 colorbar with the normal one, via subclassing and minimal modification if necessary.

@Phlya

This comment has been minimized.

Copy link
Contributor

commented Feb 18, 2019

I was just going to report almost the same issue. So just want to bring this up again... My matplotlib is 2.1.2.

a = 2**np.arange(4).reshape((2, 2))

f = plt.figure()
grid = ImageGrid(f, 111,  share_all=False,# similar to subplot(111)
                 nrows_ncols=(1, 1),
                 cbar_location="right",
                 cbar_mode="single",
                 )

m = grid[0].imshow(a, norm=LogNorm(vmax=10, vmin=1))
grid[0].cax.colorbar(m)
plt.show()

image

In particular, the colorbar should clearly have a tick at the value 1, and the strange 2×10⁰ tick on the X axis is annoying.

@timhoffm

This comment has been minimized.

Copy link
Member

commented Feb 21, 2019

The colorbar issue should probably be handled by #13397.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.