将 "all" 类别添加到 ggplots2 图
Adding "all" category to ggplots2 plot
问题
假设我想用 "all" 点的附加类别为每个类别制作密度图。我将如何着手创建这样一个数字?除了用 "all" 类别复制所有点之外,还有其他方法吗?
例子
library('ggplot2')
fig <- ggplot(iris, aes(x = Sepal.Length, color = Species)) +
stat_density(geom = "line", position = "identity")
会输出下图:
但是,我想包括另一条包含所有点的线。
ggplot(iris, aes(x = Sepal.Length, color = Species)) +
stat_density(geom = "line", position = "identity") +
stat_density(aes(x = Sepal.Length, color = "all"), geom = "line")
问题
假设我想用 "all" 点的附加类别为每个类别制作密度图。我将如何着手创建这样一个数字?除了用 "all" 类别复制所有点之外,还有其他方法吗?
例子
library('ggplot2')
fig <- ggplot(iris, aes(x = Sepal.Length, color = Species)) +
stat_density(geom = "line", position = "identity")
会输出下图:
但是,我想包括另一条包含所有点的线。
ggplot(iris, aes(x = Sepal.Length, color = Species)) +
stat_density(geom = "line", position = "identity") +
stat_density(aes(x = Sepal.Length, color = "all"), geom = "line")