Skip to content

[ENH]: Add ax.violinboxplot() for combined statistical visualization #30336

@sisird864

Description

@sisird864

Problem

matplotlib lacks a direct method to create a plot that combines a violin plot (to show data distribution) and a box plot (to show summary statistics). This is a very common and powerful visualization for statistical analysis.

Currently, users must manually overlay ax.violinplot() and ax.boxplot(). This workaround is clumsy, requires significant manual tweaking of positions and widths to get the alignment right, and can be frustrating for users trying to create a polished figure. The lack of a simple, high-level function for this common task is a gap in the library's statistical plotting capabilities.

Proposed solution

I propose adding a new helper function, ax.violinboxplot(), to provide a one-line method for creating this combined plot. 💡

This function would automatically handle the alignment, artist management, and styling, creating a clean and effective visualization out-of-the-box.

Proposed API and Behavior:

  • A new function ax.violinboxplot(data, ...) would accept standard matplotlib arguments for customization.
  • Internally, it would call ax.violinplot and ax.boxplot, intelligently positioning the box plot inside the violin.
  • It would provide a simple interface to a complex plot, improving user experience and making matplotlib more powerful for statistical plotting.

Mockup of Desired Output:

Image

I am willing to work on the implementation and submit a Pull Request for this feature. I believe it would be a valuable addition to the library.

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