Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[New Feature] Insert color fill parameter to Boxplot instead of using 'patch_artist' #17959

Copy link
Copy link
Open
@lfenzo

Description

@lfenzo
Issue body actions

Feature Request

I'm new to matplotlib and I don't know if there is a specific reason for the boxplot fill coloring to be the way it is. I only wonder if it could be done in a more straight forward manner than what is shown in here.

The idea for this "new feature" would be to use a color parameter that recieves either a list of supported colors or a single color (e.g. color = 'red') that specifies the colors to be applied to each one of the boxplots in the ax.

How it is currently done

import matplotlib.pyplot as plt
import numpy as np

data = [np.random.normal(0, std, 1000) for std in range(1, 6)]

box = plt.boxplot(data, notch=True, patch_artist=True)

colors = ['cyan', 'lightblue', 'lightgreen', 'tan', 'pink']
for patch, color in zip(box['boxes'], colors):
    patch.set_facecolor(color)

plt.show()

The idea for this 'New Feature'

import matplotlib.pyplot as plt
import numpy as np

data = [np.random.normal(0, std, 1000) for std in range(1, 6)]

colors = ['cyan', 'lightblue', 'lightgreen', 'tan', 'pink']

# or maybe 'c = colors', 'face_colors = colors'...
plt.boxplot(data, notch=True, colors = colors)

plt.show()

Any thoughts on this idea?

Matplotlib version

  • Operating system: Windows 10 2004
  • Matplotlib version: 3.2.2
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.7.7
  • Jupyter version (if applicable): 2.1.5
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.