Skip to content

[Bug]: plt.hist with bin='auto' struggles with levy-distributed points #23524

Closed as not planned
@mdhaber

Description

@mdhaber

Bug summary

plt.hist with bin='auto' struggles when the data has a long tail. This was discovered in the context of levy- and levy_l- distributed data (see scipy/scipy#14563), but I've included a pathological example below.

Code for reproduction

# natural example
from scipy.stats import levy_l
import matplotlib.pyplot as plt
r = levy_l().rvs(size=1000)
plt.hist(r, bins='auto')

# pathological example
plt.hist([1, 2, 3, 4, 1e6], bins='auto')

Actual outcome

Very-long execution, hanging, or crashing depending on the specific example. Once I got a memory error, I think.

Expected outcome

A plot

Additional information

See scipy/scipy#14563

Operating system

Windows

Matplotlib Version

3.5.2

Matplotlib Backend

module://matplotlib_inline.backend_inline

Python version

3.10.5

Jupyter version

NA

Installation

conda

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions