You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[New Feature] Insert color fill parameter to Boxplot instead of using 'patch_artist' #17959
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.
changed the title [-]Insert color fill parameter to Boxplot instead of using 'patch_artist'[/-][+][New Feature] Insert color fill parameter to Boxplot instead of using 'patch_artist'[/+]on Jul 18, 2020
Generally, I agree that it should be simpler to set the facecolor.
Setting a single color
You can already do plt.boxplot(data, notch=True, patch_artist=True, boxprops={'facecolor': 'red'}). This is slightly simpler than setting on the returned patch. But still not simple enough. Most of the time, users should not need to define patch_artist. We could change the default to patch_artist='auto' which would use patches if any of the given parameters (to be checked if boxprops is the only relevant) requires patches.
This would also open the way of maybe defaulting or always using patches. I don't see a benefit in boxes being drawn with Line2D.
Using a colors parameter directly is tempting, but IMHO not precise enough. Boxes are complex objects and there is merit in precisely speifying "facecolor of the box" using the current syntax boxprops={'facecolor': 'red'}.
Setting different colors per box
I'm -0.5 on this. We don't have per-element settings for any of the styling parameters. This would add additional complexity to an large API.
I would think that there's certainly merit in switching to always using patch_artist=True (with the relevant deprecation period, yada yada). My guess is that we simply started using Line2D, and then at some point it was realized that Patches are (nearly) strictly more powerful, at which point both options were kept for backcompat. But always using Patches is just simpler.
Will have to think about the least-breaking way to migrate. Since patch_artist changes the style in a non-trivial way, just changing the default would possibly break a lot of existing code.
Note to self: seaborn always uses patch_artist=True.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Activity
[-]Insert color fill parameter to Boxplot instead of using 'patch_artist'[/-][+][New Feature] Insert color fill parameter to Boxplot instead of using 'patch_artist'[/+]timhoffm commentedon Jul 18, 2020
Thanks for your proposal.
Generally, I agree that it should be simpler to set the facecolor.
Setting a single color
You can already do
plt.boxplot(data, notch=True, patch_artist=True, boxprops={'facecolor': 'red'}). This is slightly simpler than setting on the returned patch. But still not simple enough. Most of the time, users should not need to definepatch_artist. We could change the default topatch_artist='auto'which would use patches if any of the given parameters (to be checked ifboxpropsis the only relevant) requires patches.This would also open the way of maybe defaulting or always using patches. I don't see a benefit in boxes being drawn with Line2D.
Using a
colorsparameter directly is tempting, but IMHO not precise enough. Boxes are complex objects and there is merit in precisely speifying "facecolor of the box" using the current syntaxboxprops={'facecolor': 'red'}.Setting different colors per box
I'm -0.5 on this. We don't have per-element settings for any of the styling parameters. This would add additional complexity to an large API.
anntzer commentedon Jul 18, 2020
I would think that there's certainly merit in switching to always using patch_artist=True (with the relevant deprecation period, yada yada). My guess is that we simply started using Line2D, and then at some point it was realized that Patches are (nearly) strictly more powerful, at which point both options were kept for backcompat. But always using Patches is just simpler.
timhoffm commentedon Jul 18, 2020
Will have to think about the least-breaking way to migrate. Since
patch_artistchanges the style in a non-trivial way, just changing the default would possibly break a lot of existing code.Note to self: seaborn always uses
patch_artist=True.jklymak commentedon Oct 3, 2021
Was this closed for some reason? I think the general agreement was that it is a reasonable feature. I'll take the liberty of re-opening...
github-actions commentedon Aug 11, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!