seaborn icon indicating copy to clipboard operation
seaborn copied to clipboard

Boxenplot fliersize ?

Open agamemnonc opened this issue 3 years ago • 7 comments

Hi, is it possible to change fliersize in boxenplot, as in boxplot?

agamemnonc avatar Nov 19 '21 12:11 agamemnonc

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.

mwaskom avatar Nov 26 '21 23:11 mwaskom

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?

agamemnonc avatar Nov 29 '21 17:11 agamemnonc

Am I right in assuming the second approach would be preferable for supporting this feature?

Not sure what you mean by "second approach"?

mwaskom avatar Nov 30 '21 00:11 mwaskom

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.

agamemnonc avatar Dec 01 '21 11:12 agamemnonc

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 avatar Dec 01 '21 11:12 mwaskom

@mwaskom and @agamemnonc, i see that this issue is still open. Would you mind if i took a stab at this?

EitanHemed avatar Jul 03 '22 18:07 EitanHemed

@EitanHemed pls go ahead, I haven't managed to find time to work on this unfortunately.

agamemnonc avatar Jul 05 '22 09:07 agamemnonc

Closed with #2909

mwaskom avatar Aug 13 '22 22:08 mwaskom