wilkelab / ggridges

Ridgeline plots in ggplot2
https://wilkelab.org/ggridges
GNU General Public License v2.0
411 stars 31 forks source link

median line colored differently from 25th, 75th percentile #18

Open higgi13425 opened 6 years ago

higgi13425 commented 6 years ago

This one may already be solved.

clauswilke commented 6 years ago

Yes, I pushed a basic implementation earlier today. Need to think it over for a while to make sure I didn't forget anything. Also, if you could try it out and provide feedback that would be great.

ggplot(iris, aes(x = Sepal.Length, y = Species, vline_color = ..quantile..)) +
  geom_density_ridges(calc_ecdf = TRUE, quantile_lines = TRUE)
screen shot 2018-04-05 at 4 34 01 pm
ggplot(iris, aes(x = Sepal.Length, y = Species, vline_color = ..quantile..)) +
  geom_density_ridges(calc_ecdf = TRUE, quantile_lines = TRUE) +
  scale_discrete_manual("vline_color",
                        values = c("blue", "red", "blue", "black"), 
                        breaks = c(1, 2),
                        labels = c("1st & 3rd quartile", "median"),
                        name = NULL)
screen shot 2018-04-05 at 4 36 02 pm
clauswilke commented 6 years ago

I have removed the need for calc_ecdf = TRUE. This should work now.

ggplot(iris, aes(x = Sepal.Length, y = Species, vline_color = ..quantile..)) +
  geom_density_ridges(quantile_lines = TRUE)
lbenz730 commented 6 years ago

I get the following error when I try and copy your code above.

Picking joint bandwidth of 0.181
Error in FUN(X[[i]], ...) : object 'quantile' not found
clauswilke commented 6 years ago

Are you running the latest development code?

lbenz730 commented 6 years ago

Ah thanks! I was using the version on CRAN. Things now work as they should!