Last updated on September 27, 2025 pm
配置环境 1 2 3 conda create -n raincloud conda-forge::r-tidyverse conda-forge::r-irkernel conda-forge::r-gghalves conda-forge::r-ggbeeswarm -y conda run -n raincloud Rscript -e "IRkernel::installspec(name='raincloud', displayname='r-raincloud')"
使用示例 1 2 3 4 5 6 7 require( ggplot2) require( gghalves) require( ggbeeswarm) require( tidyverse) require( RColorBrewer) options( repr.plot.width= 6 , repr.plot.height= 12 ) RColorBrewer:: display.brewer.all( type = "all" )
1 2 data <- iris data %>% head
1 2 3 4 5 6 7 8 p <- ggplot( data, aes( x = Species, y = Sepal.Length, fill = Species, color = Species) ) p_color <- RColorBrewer:: brewer.pal( 3 , "Dark2" ) p <- p + scale_color_manual( values= rev( p_color) ) + scale_fill_manual( values= rev( p_color) )
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 p1 <- p + geom_half_violin( nudge = 0.08 , side = 'R' , trim = T , alpha = 0.9 ) + geom_beeswarm( aes( x = as.numeric ( Species) - 0.08 ) , side = - 1L , size = 2 , shape = 20 , alpha = 0.8 ) + geom_boxplot( outlier.shape = NA , width = 0.1 , alpha = 0.5 ) + coord_flip( ) + theme_bw( ) + theme( panel.grid= element_blank( ) ) options( repr.plot.width= 12 , repr.plot.height= 9 ) p1
【绘图】云雨图比较两组的分布差异
https://hexo.limour.top/distribution-differences-using-raincloud-chart