Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ax.pie() raises ValueError when input contains NaN #29860

Closed
@34wizrd

Description

@34wizrd
  • Description: When using matplotlib.pyplot.pie() with a list that includes a NaN, the function raises a ValueError. This crash is not currently caught or documented.
import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()
data = [10, 20, float('nan'), 40]
ax.pie(data, labels=["A", "B", "C", "D"])
plt.show()
  • Error Message
    ValueError: cannot convert float NaN to integer

  • Expected Behavior - matplotlib.pie() should either: Filter outNaNs, or raise a clear and user-friendly ValueError

  • Environment:

    • Python: 3.11

    • Matplotlib: 3.8.x

    • OS: Windows 10

    • Found via: Fuzz testing

[@tacaswell edited to fix markdown markup]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions