Skip to content
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

feat(experiments): violin plots #28073

Merged
merged 13 commits into from
Jan 31, 2025
Merged

feat(experiments): violin plots #28073

merged 13 commits into from
Jan 31, 2025

Conversation

andehen
Copy link
Contributor

@andehen andehen commented Jan 30, 2025

Problem

We are currently showing rectangular bars for the credible interval distribution. This does not give an accurate representation of the underlying data. It is much more likely that the value is close to the center than towards the tails.

Changes

Use violin plots as they better represent the underlying probability distribution of the data. It becomes more visible that the value is likely to be closer to the center.

Before:
Screenshot 2025-01-30 at 07 39 31

After:
Screenshot 2025-01-30 at 08 50 18

Tooltip:
Screenshot 2025-01-31 at 08 05 42

How did you test this code?

👀

@andehen andehen requested a review from a team January 30, 2025 08:01
@andehen andehen changed the title tweak(experiments): violin plots feat(experiments): violin plots Jan 30, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR enhances experiment result visualization by replacing rectangular bars with violin plots to better represent probability distributions in the DeltaChart component.

  • Added generateViolinPath function in /frontend/src/scenes/experiments/MetricsView/DeltaChart.tsx using normal distribution approximation for SVG path generation
  • Implemented gradient fills in violin plots to visually distinguish positive/negative regions
  • Simplified delta markers from rectangles to lines for cleaner visualization
  • Increased default bar height from 8px to 10px to accommodate violin plot shape
  • Added dynamic width scaling based on bar height to maintain proportional violin shapes

1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +479 to +513
<linearGradient
id={`gradient-${metricIndex}-${variant.key}`}
x1="0"
x2="1"
y1="0"
y2="0"
>
{lower < 0 && upper > 0 ? (
<>
<stop offset="0%" stopColor={COLORS.BAR_NEGATIVE} />
<stop
offset={`${(-lower / (upper - lower)) * 100}%`}
stopColor={COLORS.BAR_NEGATIVE}
/>
<stop
offset={`${(-lower / (upper - lower)) * 100}%`}
stopColor={COLORS.BAR_POSITIVE}
/>
<stop
offset="100%"
stopColor={COLORS.BAR_POSITIVE}
/>
</>
) : (
<stop
offset="100%"
stopColor={
upper <= 0
? COLORS.BAR_NEGATIVE
: COLORS.BAR_POSITIVE
}
/>
)}
</linearGradient>
</defs>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Multiple gradient definitions with the same stops are created for each variant. Consider moving the gradient definition outside the variant loop for better performance.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

3 snapshot changes in total. 0 added, 3 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Contributor

@jurajmajerik jurajmajerik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, fancy! 🎻

Can you please also update the "How to read" tooltip with a new dark screenshot? Might be also useful to update the text (along the lines of "It is much more likely that the value is close to the center than towards the tails..")

image

@andehen andehen requested a review from jurajmajerik January 31, 2025 07:07
Copy link
Contributor

@jurajmajerik jurajmajerik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andehen andehen force-pushed the experiment-violin-plots branch from 60f7e4b to 23b59ee Compare January 31, 2025 09:41
@andehen andehen enabled auto-merge (squash) January 31, 2025 10:34
Copy link
Contributor

Size Change: 0 B

Total Size: 1.16 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 1.16 MB

compressed-size-action

@andehen andehen merged commit 4285c1c into master Jan 31, 2025
99 checks passed
@andehen andehen deleted the experiment-violin-plots branch January 31, 2025 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants