seaborn
seaborn copied to clipboard
Boxenplot fliersize ?
Hi, is it possible to change fliersize
in boxenplot
, as in boxplot
?
Unfortunately not; unlike with boxplot
there's no single underlying matplotlib function to pass kwargs
for; they're passed to the patches as those make up the main part of the plot.
You could either:
- Temporarily modify the default marker size (
with plt.rc_context({"lines.markersize": 2}): ...
) - Modify the artist properties after plotting
plt.setp(ax.collections[::2], sizes=[2 ** 2])
I think this would be a good feature if you want to add it. It should probably be a flier_kws
option rather than fliersize
because people might want to change other parameters (shape, etc.) too.
Thanks @mwaskom. Sure, I would be happy to work on a PR on this (and might need some guidance along the way).
Am I right in assuming the second approach would be preferable for supporting this feature?
Am I right in assuming the second approach would be preferable for supporting this feature?
Not sure what you mean by "second approach"?
I mean using plt.setp(ax.collections[::2], sizes=[2 ** fliersize])
as opposed to with plt.rc_context({"lines.markersize": fliersize}):
Or did I perhaps misunderstand and these two approaches are just suggested as temporary workarounds, and you had sth else in mind for properly addressing this issue? Please let me know.
Right, those are both workarounds for users who can only interact with the matplotlib figure object that seaborn creates. Inside the function, you can pass the dictionary of flier_kws
to the scatter
call that draws the outliers.
Actually looking at the code a little bit, the situation with kws
is messier than I thought, because kws
is passed to both plot
(to draw the medians) and scatter
to draw the outliers, with no ability to tweak the appearance of the boxes externally.
So ideally, there would be three new parameters:
-
box_kws
-
line_kws
-
flier_kws
And they would each be dispatched to the right place.
Two other pieces of guidance for how to make this change:
- You should add the plotting parameters that are currently passed to each function (like the flier shape) to the kws dictionary using
.setdefault
so that users can override the defaults if desired. - You don't want to mutate the user's dictionary when you do that, so you need to copy the kwargs dicts first.
@mwaskom and @agamemnonc, i see that this issue is still open. Would you mind if i took a stab at this?
@EitanHemed pls go ahead, I haven't managed to find time to work on this unfortunately.
Closed with #2909