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

Colorbar for imshow messes interactive cursor with masked data #15103

Closed
Descanonge opened this issue Aug 22, 2019 · 3 comments · Fixed by #15140
Closed

Colorbar for imshow messes interactive cursor with masked data #15103

Descanonge opened this issue Aug 22, 2019 · 3 comments · Fixed by #15140

Comments

@Descanonge
Copy link

Bug report

Adding a colorbar when the mappable is the result of imshow for a masked array changes the behavior of the interactive z-data cursor and triggers a UserWarning.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

mask = np.zeros((4, 4), bool)
mask[:2] = True
A = np.ma.array(np.random.rand(4, 4), mask=mask)

fig, ax = plt.subplots(1, 1)
im = ax.imshow(A)
fig.colorbar(im)

Actual outcome

~/.anaconda3/lib/python3.7/site-packages/matplotlib/ticker.py:632: UserWarning: Warning: converting a masked element to nan.
  return '%-12g' % value

Screenshot from 2019-08-22 18-22-23

Expected outcome
Before adding the colorbar, the zdata cursor shows a blank ([]).

Matplotlib version

  • Operating system: Linux
  • Matplotlib version: 3.1.1
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.7.3
  • IPython version: 7.2.0
  • Other libraries:
    Matplotlib installed from pip.
@jklymak
Copy link
Member

jklymak commented Aug 22, 2019

Any idea if this is a change of behaviour from previous versions? I know that the formatter changes to use the colorbar's formatter if its available, but not sure when that was introduced.

@jklymak jklymak added this to the v3.3.0 milestone Aug 22, 2019
@Descanonge
Copy link
Author

I don't remember this warning ever coming up until recently.
After a bit of rollback, it seems this issue appeared with 3.1.0.

@ImportanceOfBeingErnest
Copy link
Member

Bisects to #12459

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants