8000 [Bug]: matplotlib 3.3 changed how plt.hist handles iterables of zero-dimensional arrays. · Issue #22016 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
[Bug]: matplotlib 3.3 changed how plt.hist handles iterables of zero-dimensional arrays. #22016
Closed
@jakevdp

Description

@jakevdp

Bug summary

matplotlib 3.3 changed how plt.hist handles iterables of zero-dimensional arrays. This has come up because JAX has no scalar type, and recently changed its iteration protocol to return zero-dimensional JAX arrays rather than numpy scalars (see jax-ml/jax#8899). But note that this issue can be reproduced without JAX, and is a case where matplotlib changed its behavior between version 3.2.2 and version 3.3.0.

Code for reproduction

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
data = [np.asarray(i) for i in [1, 2, 2, 3, 3, 3, 4, 4, 5]]
<
5CC1
span class="pl-s1">plt.hist(data)
plt.title(f'matplotlib version={matplotlib.__version__}')

Actual outcome

Outcome in matplotlib 3.2.2:
download-4

Outcome in matplotlib 3.3.0:
download-5

Expected outcome

I expect that version 3.3.0 and later will produce the same chart as 3.2.2 and earlier.

Additional information

No response

Operating system

No response

Matplotlib Version

3.3.0 and newer

Matplotlib Backend

No response

Python version

all Python versions

Jupyter version

No response

Installation

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0