Skip to content

[ENH]: Add color argument to violinplot constructor #27298

Closed
@landoskape

Description

@landoskape

Problem

It would be nice to specify the color of a set of violin plots in the constructor, rather than doing it afterwards for each component of the violinplot. This is usually how colors are set in matplotlib, so it would be in keeping with the general schema of matplotlib.

I can set this up as a PR if people think it's useful and makes sense for the library.

Proposed solution

The current color selection is done here. It looks like this:

        # Colors.
        if mpl.rcParams['_internal.classic_mode']:
            fillcolor = 'y'
            linecolor = 'r'
        else:
            fillcolor = linecolor = self._get_lines.get_next_color()

The proposed enhancement would look something like this, where color is a new key word argument with default value =None.

        # Colors.
        if mpl.rcParams['_internal.classic_mode']:
            fillcolor = 'y'
            linecolor = 'r'
        elif color is not None:
            fillcolor = linecolor = color 
        else:
            fillcolor = linecolor = self._get_lines.get_next_color()

This could even work for a sequence of colors, but a little bit more code would have to be changed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions