Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Colorbar for imshow messes interactive cursor with masked data #15103

Copy link
Copy link
Closed
@Descanonge

Description

@Descanonge
Issue body actions

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.