R 如何将几何点添加到统计密度脊线
我能用这段代码画出密度线。我想在不改变当前设计的情况下,在百分位0.50处添加geom_点。任何帮助都将不胜感激R 如何将几何点添加到统计密度脊线,r,ggplot2,ggridges,R,Ggplot2,Ggridges,我能用这段代码画出密度线。我想在不改变当前设计的情况下,在百分位0.50处添加geom_点。任何帮助都将不胜感激 library(ggplot2) library(ggridges) ggplot(iris, aes(x=Sepal.Length, y=Species, fill = factor(stat(quantile)))) + stat_density_ridges( geom = "density_ridges_gradient", calc_ecdf = TRUE,
library(ggplot2)
library(ggridges)
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
)
试试看
p + geom_point(data = aggregate(Sepal.Length ~ Species, iris, median),
aes(x = Sepal.Length, y = Species),
color = "red",
size = 5,
inherit.aes = FALSE)
(一路上你一定叫调色板了)
数据
library(ggplot2)
library(ggridges)
p <- 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
)
库(ggplot2)
图书馆(GG)
P