- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如果我想为 ggridge
对象添加一个点估计,但我一直收到错误:
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
最佳答案
可以通过在geom_point
调用中指定inherit.aes = F
来解决问题:
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)
只产生以下信息:
选取 0.181 的联合带宽
编辑:另一种方法(感谢@Axeman 的评论)是将 fill
美学移动到 stat_density_ridges
层。
关于r - 将 geom_point 添加到 ggridges,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50345984/
我有一个包含长度(整数)和年份(因子)的数据集,我想使用 ggridges 绘制它。这是一个包含整数和因子数据的类似数据集。如何更改 y 轴上 Species(即因子)的顺序? library(ggp
如何更改 ggridges 图的缩放比例,使绘图更像直方图,而不像核密度图?也就是说,我希望该图反射(reflect)分类变量的不同大小。 例如 library(tidyverse) library(
我想使用 ggridges 为喜悦图逐行添加一条垂直线. # toy example ggplot(iris, aes(x=Sepal.Length, y=Species, fill=..x..))
ggridges 包允许您使用任一纯色绘制山脊图: ggplot(iris, aes(x=Sepal.Width, y=Species))+ geom_density_ridges(alpha=0.3
请查看以下一年中不同月份的温度直方图。我将温度限制在 50 度以上,以便在较冷的月份有目的地强制某些直方图变小。记下第 1 个月、第 2 个月和第 3 个月,它们太小了,几乎没有记录在侧面图上。 li
如果我想为 ggridge 对象添加一个点估计,但我一直收到错误: library(ggplot2) library(ggridges) iris_med % group_by(Species) %>
是否可以使用 ggridges 包来绘制多组条形图而不是山脊线,类似于 geom_col()? 我有如下数据: dt = tibble( hr = c(1,2,3,4,1,2,3,4),
我目前正在与 ggridges 库合作,以制作“joychart”。我是这样写的: data3 %>% mutate(ftFct = fct_rev(as.factor(ft_newnum)))
我是一名优秀的程序员,十分优秀!