TidierOrg / TidierPlots.jl

Tidier data visualization in Julia, modeled after the ggplot2 R package.
MIT License
196 stars 7 forks source link

Use of `aes(color=category)` in `geom_density` or `geom_hist` #102

Closed dmbates closed 2 months ago

dmbates commented 2 months ago

Describe how it works in R's ggplot2 A clear and concise description of what you want to happen.

If x is a numeric variable and g is a factor in data.frame df in R then ggplot(df, aes(x = x, color=g) + geom_density() produces a plot with multiple kernel density estimates. See the diamonds example in https://ggplot2.tidyverse.org/reference/geom_density.html

In TidierPlots.jl it seems that the color/colour aesthetic is interpreted as a scalar color by geom_density.

Is there a way to create a plot with multiple kernel density curves in TidierPlots.jl?

BTW, @rdboyes It is great to see someone from the Kingston area (are you on Wolfe Island?) in Julia development. I did both my undergraduate degree and my Ph.D. at Queens.

rdboyes commented 2 months ago

Yep! Wolfe Island - just finished my Ph.D at Queen's last year.

Thanks for reporting this - it's another issue downstream of the grouping issue (like #93) - looks like @adknudson has an idea how to fix it over there so we should have this working soon!

rdboyes commented 2 months ago

In dev branch now:

ggplot(penguins) +
         geom_density(aes(x = :bill_length_mm, color = :island))

image