最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

ggplot繪制山嵐圖

2023-08-27 15:28 作者:五柳冰冰  | 我要投稿

## 山嵐圖

```{r}
library(ggridges)
p <- ggplot(iris, aes(x = Sepal.Length, 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數(shù)值著色

```{r}
p1 <- ggplot(iris, aes(x = Sepal.Length, y = Species,fill=after_stat(x)))

p1 + geom_density_ridges_gradient(scale = 1)

p1 + geom_density_ridges_gradient(scale = 1)+scale_fill_viridis_c()

```

添加分位數(shù)的線

```{r}
p+stat_density_ridges(quantile_lines = TRUE, quantiles = c(0.025, 0.975), alpha = 0.7)

p+stat_density_ridges(quantile_lines = TRUE, quantiles = c(0.025, 0.975), alpha = 0.7,scale = 1)
```

按分位數(shù)的線分割著色

```{r}
ggplot(iris, aes(x=Sepal.Length, 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")
```

按分位數(shù)的線分割著色2

```{r}
ggplot(iris, aes(x = Sepal.Length, y = Species, fill = factor(stat(quantile)))) +
? stat_density_ridges(
??? geom = "density_ridges_gradient",
??? calc_ecdf = TRUE,
??? quantiles = c(0.025, 0.975),
??? scale = 1 ) +
? scale_fill_manual(
??? name = "Probability", values = c("#FF0000A0", "pink", "pink"),
??? labels = c("(0, 0.025]", "(0.025, 0.975]", "(0.975, 1]")
? )
```
按概率密度值著色

```{r}
ggplot(iris, aes(x = Sepal.Length, y = Species, fill = 0.5 - abs(0.5 - stat(ecdf)))) +
? stat_density_ridges(geom = "density_ridges_gradient", calc_ecdf = TRUE,scale = 1) +
? scale_fill_viridis_c(name = "概率密度", direction = -1)
```


ggplot繪制山嵐圖的評論 (共 條)

分享到微博請遵守國家法律
增城市| 天津市| 桐乡市| 双流县| 德保县| 金寨县| 海兴县| 休宁县| 常宁市| 周至县| 长宁区| 阜新| 安阳县| 沅江市| 南投市| 剑阁县| 乌拉特后旗| 阳朔县| 老河口市| 辽宁省| 延安市| 玉屏| 马关县| 吉林市| 蓬溪县| 西峡县| 常熟市| 磴口县| 颍上县| 嘉鱼县| 浦县| 东阳市| 义乌市| 区。| 静宁县| 曲松县| 遂溪县| 斗六市| 南通市| 巩义市| 漳浦县|