Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign uppyplot.stem does not support subclasses of numpy.ndarray #16343
Labels
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Bug report
Bug summary
pyplot.stem does not support subclasses of numpy.ndarray that have defined the matplotlib.units.ConversionInterface. In the example below, I am using the unyt library where
unyt_arrayis a np.ndarray subclass and the library has defined the units.ConversionInterface. pyplot.plot works as expected, but pyplot.stem never calls the ConversionInterface.The problem is in _axes.py in the first line of pyplot.stem where
y = np.asarray(y)converts theunyt_arrayto a pure np.ndarray and the subsequent liney = self.convert_yunits(y)never calls the ConversionInterface because y is now a np.ndarray. Changing the first line toy = np.asanyarray(y)fixes the problem allowing the subclass to pass through.Is it possible for matplotlib to update pyplot.stem to support np.ndarray subclasses?
Code for reproduction
Actual outcome
Expected outcome
Matplotlib version
print(matplotlib.get_backend())): TkAgg