首页 热点 业界 科技快讯 数码 电子消费 通信 前沿动态 电商

ggplot绘制山岚图

2023-08-28 03:28:06 来源 : 哔哩哔哩


(资料图片仅供参考)

## 山岚图```{r}library(ggridges)p <- ggplot(iris, aes(x = , y = Species,fill=Species)) p+ geom_density_ridges(alpha=.5)p+ geom_density_ridges2(alpha=.5)p+ geom_density_ridges(alpha=.5,scale = 1)p+ geom_density_ridges(alpha=.5,scale = 2)p+ geom_density_ridges(alpha=.5,scale = .9)```按照x数值着色```{r}p1 <- ggplot(iris, aes(x = , y = Species,fill=after_stat(x))) p1 + geom_density_ridges_gradient(scale = 1)p1 + geom_density_ridges_gradient(scale = 1)+scale_fill_viridis_c()```添加分位数的线```{r}p+stat_density_ridges(quantile_lines = TRUE, quantiles = c(, ), alpha = )p+stat_density_ridges(quantile_lines = TRUE, quantiles = c(, ), alpha = ,scale = 1)```按分位数的线分割着色```{r}ggplot(iris, aes(x=, y=Species, fill = factor(stat(quantile)))) +  stat_density_ridges(    geom = "density_ridges_gradient", calc_ecdf = TRUE,    quantiles = 4, quantile_lines = TRUE,    scale = 1) +  scale_fill_viridis_d(name = "Quartiles")```按分位数的线分割着色2```{r}ggplot(iris, aes(x = , y = Species, fill = factor(stat(quantile)))) +  stat_density_ridges(    geom = "density_ridges_gradient",    calc_ecdf = TRUE,    quantiles = c(, ),    scale = 1 ) +  scale_fill_manual(    name = "Probability", values = c("#FF0000A0", "pink", "pink"),    labels = c("(0, ]", "(, ]", "(, 1]")  )```按概率密度值着色```{r}ggplot(iris, aes(x = , y = Species, fill = - abs( - stat(ecdf)))) +  stat_density_ridges(geom = "density_ridges_gradient", calc_ecdf = TRUE,scale = 1) +  scale_fill_viridis_c(name = "概率密度", direction = -1)```

标签:

相关文章

最近更新
ggplot绘制山岚图 2023-08-28 03:28:06
问界的反攻开始了 2023-08-28 02:26:54
思享无限美股涨8.15% 2023-08-28 02:42:23
问界的反攻开始了 2023-08-28 02:26:54
关于300529的一些信息 2023-08-28 02:21:35