Skip to content

Masked arrays not working with categorical data #19722

Open
@juliospain

Description

@juliospain

Bug report

Bug summary

Masked arrays are nicely supported by MPL. The masked data is not plotted and even the line interrupted.
However, when the data is str (categorical) the mask is completely ignored.

Code for reproduction

import numpy.ma
x = range(3)
y = numpy.ma.array(['hello', 'bye', 'bye2'], mask=[False, True, False])
plt.plot(x,y)
plt.show()

Actual outcome

image

Expected outcome

Probably the "bye" label should not even be put in the y-axis.
There should be no line but two "dots" in hello and bye2.

Matplotlib version

  • Operating system: Windows
  • Matplotlib version (import matplotlib; print(matplotlib.__version__)): 3.3.4
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.8

Installed from conda-forge

Metadata

Metadata

Assignees

No one assigned

    Labels

    keepItems to be ignored by the “Stale” Github Actiontopic: categorical

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions