Weird behavior with pint.Quantity + masked array · Issue #8908 · matplotlib/matplotlib · GitHub
Skip to content

Weird behavior with pint.Quantity + masked array #8908

Description

@dopplershift

From my SciPy 2017 talk, the combination of pint.Quantity for unit support with masked arrays produces problems not seen with either individually:

%matplotlib inline

import matplotlib.pyplot as plt
import numpy as np
import pint

units = pint.UnitRegistry()

data = np.random.randn(30,)
data_units = data * units.meters
data_masked = np.ma.array(data, mask=data<0.)
data_masked_units = data_masked * units.meters

fig, axes = plt.subplots(1, 3, sharex=True, sharey=True, figsize=(8, 4))
axes[0].plot(data_units)
axes[1].plot(data_masked)
axes[2].plot(data_masked_units)

produces:

bug

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions