R ggplot : overlaying a kernel density chart on the y axis of a plot

标签 r ggplot2

我有一个 ggplot 图表

q3 <- ggplot(y, aes(T,C))+  geom_line() 

和内核密度

den <-density(y$C)      

如何在 y 轴上叠加内核密度图?

感谢您的帮助

最佳答案

按照 DWin 的想法,这可能就是您正在寻找的东西:

dat <- data.frame(x = 1:100,
                  y = 1:100,
                  z = rnorm(100))

ggplot(dat) + 
    geom_point(aes(x = y/100,y = x/100)) + 
    geom_density(aes(x = z)) + 
    coord_flip()

enter image description here

请注意 geom_pointxy 美学的逆转。

关于R ggplot : overlaying a kernel density chart on the y axis of a plot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11313739/

相关文章:

r - 根据列号选择值

r - scale_gradientn 中的陡峭梯度

r - 将多个变量传递给 ggtitle R

r - st_normalize.sfc(x, c(x_range[1], y_range[1], x_range[2], y_range[2])) 中的错误 : domain must have a positive range

r - ggplot2错误:手动刻度中的值不足

regex - 使用 `gsub` 替换点

r - 使用移动平均或内核平滑对二进制变量进行平滑

c - .C 到 R 的接口(interface)

r - Hmisc 包和 Knit 中的 Latex() 生成的 Latex 表的奇怪行为

r - 用于静态报告的类似 Valuebox 的函数