Skip to content

[Bug]: violinplot crashes on empty datasets #31700

@anntzer

Description

@anntzer

Bug summary

When one of the datasets passed to boxplot is empty, no boxplot is drawn for that dataset. When the same is done for violinplot, violinplot crashes; instead it would be convenient if it behaved like boxplot (draw nothing for the empty dataset).

Code for reproduction

plt.boxplot([np.random.randn(sz) for sz in [100, 0, 200]])  # ok
plt.violinplot([np.random.randn(sz) for sz in [100, 0, 200]])  # crashes

Actual outcome

Second line crashes with

ValueError: zero-size array to reduction operation minimum which has no identity

Expected outcome

Empty violinplot for the second (empty) dataset.

Additional information

No response

Operating system

macOS

Matplotlib Version

3.12.0.dev68+g1cb6fe289

Matplotlib Backend

any

Python version

3.14.0

Jupyter version

ENOSUCHLIB

Installation

git checkout

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions