DABEST-python icon indicating copy to clipboard operation
DABEST-python copied to clipboard

Optionally color paired plots

Open siemdejong opened this issue 8 months ago • 4 comments

Is your feature request related to a problem? Please describe.

groups_baseline = dabest.load(df, idx=("1", "2", "3", "4", "5"), paired="baseline", idx="id")

doesn't show a colored plot

Describe the solution you'd like Have colors when using paired=..., just like there is if there is no paired=.... The structure of the plot can stay the same.

Describe alternatives you've considered Do

groups_no_baseline = dabest.load(df, idx=("1", "2", "3", "4", "5"))

but this removes the "pairing line" between the datapoints and the mean difference should be paired.

Additional context

Image (labels censored)

This issue results from the following experimental setup:

  1. divide data in 10 groups (3 shown above)
  2. for every group, do 5 experiments So there is pairing via the 10 groups.

siemdejong avatar Apr 28 '25 10:04 siemdejong

Paired plots are currently displayed as a slopegraph - paired lines without markers. There would therefore be no aesthetic logic for color coding each group. Is your suggestion that we should include markers for each data point in each group (and color these) as well as including the slopegraph (black lines)?

JAnns98 avatar Apr 30 '25 06:04 JAnns98

The slopegraph without markers is fine.

Let me try to explain better. My suggestion would be to have an argument to color the bars and the paired mean difference distribution like done in the plot on the right.

I think, that https://github.com/ACCLAB/DABEST-python/blob/5d83bb12d6e58343881fe10869b7650f06b9c3c2/dabest/plot_tools.py#L1271 and https://github.com/ACCLAB/DABEST-python/blob/5d83bb12d6e58343881fe10869b7650f06b9c3c2/dabest/plot_tools.py#L31 https://github.com/ACCLAB/DABEST-python/blob/5d83bb12d6e58343881fe10869b7650f06b9c3c2/dabest/plot_tools.py#L47 make the colors gray/black by default and does not allow for each bar to have a distinct color.

Something like what is done here https://github.com/ACCLAB/DABEST-python/blob/5d83bb12d6e58343881fe10869b7650f06b9c3c2/dabest/plot_tools.py#L1364 may already be enough.

siemdejong avatar May 01 '25 07:05 siemdejong

Ooh i see, you would like to be able to have the colored groups for the bars and the halfviolins. I will look into the cleanest way to implement this if we do decide to - will get back to you :)

JAnns98 avatar May 02 '25 01:05 JAnns98

A suggestion: it would be great if it was compatible with plt.style.use(...) so that users can use any color cycle.

siemdejong avatar May 02 '25 14:05 siemdejong

if we do decide to

Have you decided if this is something that could be added?

siemdejong avatar Aug 06 '25 08:08 siemdejong

Hi! Apologies for the long delay. I am working on it at the moment. We are also doing some modifications to the default plotting format of the slopegraph plots. So far I have added this functionality if the user specifies a custom_palette in the plotting function - ie., if the user doesn't specify a custom_palette, it will remain black/grey

Image

JAnns98 avatar Aug 14 '25 11:08 JAnns98

This feature has now been pushed to the dev (vnbdev) branch

JAnns98 avatar Aug 26 '25 04:08 JAnns98