-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ENH: passing colors (and other optional keyword arguments) to violinplot() #3875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6870,15 +6870,15 @@ def matshow(self, Z, **kwargs): | |
|
||
def violinplot(self, dataset, positions=None, vert=True, widths=0.5, | ||
showmeans=False, showextrema=True, showmedians=False, | ||
points=100, bw_method=None, color='y', line_kw={}, | ||
points=100, bw_method=None, color='y', line_kw=None, | ||
**fill_kw): | ||
"""Make a violin plot. | ||
|
||
Call signature:: | ||
|
||
violinplot(dataset, positions=None, vert=True, widths=0.5, | ||
showmeans=False, showextrema=True, showmedians=False, | ||
points=100, bw_method=None, color='y', line_kw={}, | ||
points=100, bw_method=None, color='y', line_kw=None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should probably change this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. definitely would want to change color to None. Who knows? Maybe it might make sense to have color-cycling on this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I also drop the old default values for the line colors and fill alpha? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a tough one to decide. There are no corollary values in the rcparams to pull from instead of these hard-coded values. But I hate hard-coded values so much! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @WeatherGod I share your hatred for hard-coded values, but I also think all plots ought to look reasonably good with just the default parameters. If I get rid of the hard-coded values for facecolor, linecolor and alpha, the violins look a little bit lacklustre: Do you reckon that's acceptable, or should I go back to the default values? |
||
**fill_kw): | ||
|
||
Make a violin plot for each column of *dataset* or each vector in | ||
|
@@ -6986,14 +6986,14 @@ def _kde_method(X, coords): | |
|
||
def violin(self, vpstats, positions=None, vert=True, widths=0.5, | ||
showmeans=False, showextrema=True, showmedians=False, | ||
color='y', line_kw={}, **fill_kw): | ||
color='y', line_kw=None, **fill_kw): | ||
"""Drawing function for violin plots. | ||
|
||
Call signature:: | ||
|
||
violin(vpstats, positions=None, vert=True, widths=0.5, | ||
showmeans=False, showextrema=True, showmedians=False, | ||
color='y', line_kw={}, **fill_kw): | ||
color='y', line_kw=None, **fill_kw): | ||
|
||
Draw a violin plot for each column of `vpstats`. Each filled area | ||
extends to represent the entire data range, with optional lines at the | ||
|
@@ -7124,6 +7124,9 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5, | |
elif len(color) != N: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure we want to check the length, this will prevent passing in things like I also think that there are tools in cookbook that do this with all of the bells and whistles/corner cases covered. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can see the reason for separating them, and there is some precedence for it. This plotting function produces a mix of artist types, each of which may need to be stylized differently. If I pass a linewidth argument, am I referring to the width of the lines for the polygon edges or what? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @WeatherGod Indeed, and I think that would actually be quite a common use case. For example, it's unlikely that I'd want to set the same line color for the polygon edges and the lines marking the medians etc. since they would have poor color contrast. In fact I was specifically thinking of |
||
raise ValueError(datashape_message.format("color")) | ||
|
||
if line_kw is None: | ||
line_kw = {} | ||
|
||
# original default values for line color and alpha | ||
line_color = line_kw.pop('colors', 'r') | ||
alpha = fill_kw.pop('alpha', 0.3) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fill_kw
->kwargs
if you want to leave this as-is, but I don't really see why to treat the line properties differently from the fill properties.