Sayani07 / gghdr

Plots of highest density regions (HDR) for ggplot2
https://sayani07.github.io/gghdr/
GNU General Public License v3.0
47 stars 5 forks source link

Add conditional density estimation #12

Open sparce opened 4 years ago

sparce commented 4 years ago

Started in 91eeaf096da884c3167416dea56ea1610f958a65, but needs some testing because I'm sure I've broken something unexpected.

No x

ggplot(faithful, aes(y = waiting)) + 
    geom_hdr_boxplot(fill="steelblue") + 
    theme_minimal()

no_x

Categorical x

ggplot(faithful, aes(x = eruptions > 3, y = waiting)) + 
    geom_hdr_boxplot(fill="steelblue") + 
    theme_minimal()

factor_x

Numeric x

ggplot(faithful, aes(x = eruptions, y = waiting)) + 
    geom_hdr_boxplot(fill="steelblue") + 
    theme_minimal()

numeric_x

with overlaid points for good measure

ggplot(faithful, aes(x = eruptions, y = waiting)) + 
    geom_hdr_boxplot(fill="steelblue") + 
    geom_point(alpha = 0.3) +
    theme_minimal()

numeric_x_with_points

thomas-fung commented 4 years ago

These look awesome! 👍

mitchelloharawild commented 4 years ago

Amazing! :bee:

dvanic commented 4 years ago

That looks beautiful! What else is missing from @mitchelloharawild original design implementation?

sparce commented 4 years ago

Good question @dvanic, I can't quite read that whiteboard pic in the other repo 😀 Maybe we should start another issue here for that discussion.

Sayani07 commented 4 years ago

Hi @sparce could you push these changes to the repo so that I can test it? Right now with the following code it says - ggplot(faithful, aes(x = eruptions, y = waiting)) + geom_hdr_boxplot(fill="steelblue") + theme_minimal() gives the error message

Warning messages: 1: Continuous x aesthetic -- did you forget aes(group=...)? 2: Computation failed in stat_hdrcde(): Conditional density estimation is not yet supported. Make sure each plot group contains only one x value.

sparce commented 4 years ago

@Sayani07 are you trying in the cde branch?

Sayani07 commented 4 years ago

Oh no! Thank you