Add paired_raincloud() for repeated-measures connecting lines - #57
Open
pengkodammaya wants to merge 2 commits into
Open
Add paired_raincloud() for repeated-measures connecting lines#57pengkodammaya wants to merge 2 commits into
pengkodammaya wants to merge 2 commits into
Conversation
Implements the repeated-measures roadmap item as a dedicated function, paired_raincloud(), rather than new parameters on RainCloud (per the design discussion on the issue). It wraps RainCloud for the standard cloud/box/rain drawing, then connects each subject's rain points across categories for paired / pre-post / longitudinal data. RainCloud itself is unchanged. hue/dodge raise ValueError, since the point-to-subject mapping is ambiguous with dodged sub-groups. Adds the _draw_repeated_measures_lines helper, the paired_data fixture, the TestPairedRaincloud test class, and a standalone tutorial notebook on the AnxietyPaper dataset. Drafted with assistance from Claude (Anthropic).
Example renders embedded in the PR write-up: the pre/post paired demo, the AnxietyPaper tutorial data with connecting lines, and a standard RainCloud showing unchanged behaviour.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #56.
What
Implements the repeated-measures roadmap item as a dedicated function,
paired_raincloud()(per the design discussion on the issue — keepingRainCloud's signature untouched). It draws a standard raincloud and connectseach subject's rain points across categories, making within-subject change
visible for paired / pre-post / longitudinal designs.
Pre→post on 30 subjects: each thin line is one subject, so within-subject change is visible on top of the group distributions.
How
paired_raincloud()wrapsRainCloud()— it calls it for all the existingcloud/box/rain drawing (so styling stays identical and in one place), then adds
the connecting lines on top.
RainClouditself is not modified at all.stripplot; seaborn doesn't expose thejittered coordinates, so a private helper
_draw_repeated_measures_lines()recovers them from the rain
PathCollectionoffsets (the cloud is aPolyCollectionand the box is patches/lines, so the rain is the onlyPathCollectionadded) and matches each point back to its subject using thewithin-category row order of
data, which seaborn preserves.NaNmeasurements are filtered to keep that row-order matching aligned with thepoints seaborn actually drew, so a missing observation simply breaks that
subject's line instead of misaligning everything.
Scope / limitations (v1)
hue/ no-dodgecase (the overwhelmingly common one).hue/dodgeare not accepted — with dodged sub-groups thepoint→subject mapping is ambiguous, so they raise a clear
ValueErrorratherthan silently drawing something wrong. Extending to dodged sub-groups is a
sensible follow-up.
Backwards compatibility
Purely additive — a new function plus a private helper.
RainCloudis untouched,so existing behaviour is byte-for-byte unchanged.
RainCloudoutput is exactly as before.Tests
Adds
TestPairedRaincloud(+ apaired_datafixture inconftest.py):RainClouddraws no per-subject lines;NaNmeasurements don't error;hue/dodgeraiseValueError;move,point_size) forward toRainCloud.All green locally on seaborn 0.13.2 / matplotlib 3.x.
Docs
id/line_color/line_alpha/line_width).(
tutorial_python/tutorial_repeated_measures.ipynb) using the existing BristolAnxietyPaper dataset — which is already repeated-measures, so the feature
drops straight in.
The feature on the tutorial's own AnxietyPaper data: each participant connected across the four emotion conditions.