njudd / ggrain

{package} Make beautiful Raincloud plots in R!
Other
67 stars 4 forks source link

How to add stat_compare_means into boxplot in geom_rain #9

Closed vincentguo0418 closed 11 months ago

vincentguo0418 commented 11 months ago

Hi! I have three questions:

  1. How can I add a statistical test result (eg, stat_compare_means) on the boxplot?
  2. How to remove the dotplot?
  3. How to add legend?

I appreciate any help.

njudd commented 11 months ago

Most of your questions are more general ggplot functionality, yet I tried to help as much as possible.

1) you just add it as you would with any ggplot syntax (see the last example on the vignette; yet any gg package add on will work, you might just need to change the position arguments accordingly) 2) you make the color arg NA

library(ggrain)
ggplot(iris, aes(1, Sepal.Width)) +
    geom_rain(point.args = list(color = NA)) +
    theme_classic() +
    theme(axis.title.x = element_blank(), 
          axis.text.x = element_blank(), axis.ticks.x = element_blank())

3) Not sure on the issue you are having without seeing a reproducible example. In the vignette, the only reason we do not see legends is because of the following line guides(fill = 'none', color = 'none')

Hope this answers your questions all the best!