首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >向ggridges添加geom_point

向ggridges添加geom_point
EN

Stack Overflow用户
提问于 2018-05-15 08:50:44
回答 1查看 444关注 0票数 3

如果我想向一个ggridge对象添加一个点估计,但是我总是得到一个错误:

代码语言:javascript
复制
library(ggplot2)
library(ggridges)

iris_med <- iris %>% group_by(Species) %>% summarise(Sepal.Length = median(Sepal.Length))

ggplot(iris, aes(x = Sepal.Length, y = Species, fill = 0.5 - abs(0.5-..ecdf..))) +
  stat_density_ridges(geom = "density_ridges_gradient", calc_ecdf = TRUE) +
  geom_point(aes(x = Sepal.Length, y = Species, color = "red"), data = iris_med)

Picking joint bandwidth of 0.181
Error in eval(expr, envir, enclos) : object 'ecdf' not found

我希望达到的产出:

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-15 08:58:24

这个问题可以通过在inherit.aes = F调用中指定geom_point来解决:

代码语言:javascript
复制
ggplot(iris, aes(x = Sepal.Length, y = Species, fill = 0.5 - abs(0.5-..ecdf..))) +
  stat_density_ridges(geom = "density_ridges_gradient", calc_ecdf = TRUE) +
  geom_point(aes(x = Sepal.Length, y = Species, color = "red"), data = iris_med, inherit.aes = F)

只产生他以下的信息:

Picking joint bandwidth of 0.181

编辑:另一种方法(感谢@Axeman的评论)是将fill美学移到stat_density_ridges层。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50345984

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档