在多面图中包含聚合组
Include aggregate group in facetted plot
我有以下数据和图表
c1 <- seq(1,100,1)
c2 <- rnorm(100,0,1)
c3 <- rep(c(1,2,3,4),25)
dat <- data.frame(cbind(c1,c2,c3))
library(ggplot2)
ggplot(dat, aes(x = c1, y = c2, color = as.factor(c3))) +
geom_line()
我怎样才能包括一条线(也在图例中)来描述 c3 的聚合,即人们将使用的线
ggplot(dat, aes(x = c1, y = c2)) +
geom_line()
提前致谢。
这可能是一个简单的解决方法:
dat0<-dat
dat0$c3="All"
dat1<-rbind(dat,dat0)
ggplot(dat1, aes(x = c1, y = c2, color = as.factor(c3))) +geom_line()
我有以下数据和图表
c1 <- seq(1,100,1)
c2 <- rnorm(100,0,1)
c3 <- rep(c(1,2,3,4),25)
dat <- data.frame(cbind(c1,c2,c3))
library(ggplot2)
ggplot(dat, aes(x = c1, y = c2, color = as.factor(c3))) +
geom_line()
我怎样才能包括一条线(也在图例中)来描述 c3 的聚合,即人们将使用的线
ggplot(dat, aes(x = c1, y = c2)) +
geom_line()
提前致谢。
这可能是一个简单的解决方法:
dat0<-dat
dat0$c3="All"
dat1<-rbind(dat,dat0)
ggplot(dat1, aes(x = c1, y = c2, color = as.factor(c3))) +geom_line()