据我所知,geom_area和geom_line绘制变量的方式不同,因此区域彼此重叠(它们的y轴起点不同),而geom_line则交叉且重叠。你知道为什么吗?
我想要以下之一:
谢谢
dataA <- tibble::tibble(
value = c(10,20,30,30,20,10,5,8,10,8,7,2,9,25,28,29,15,6),
Sample = rep(c(1:6),3),
Variable = rep(c(rep("C1",6),rep("C2",6),rep("C3",6))),
Case = rep(c(rep("o",6), rep("a",6),rep("o",6))))
#This is the geom_area graph
p1 <- ggplot(dataA, aes(x=Sample, y=value, fill=Variable)) +
geom_area(colour="black", size=.2, alpha=.8) +
theme_bw()
#This is the geom_line
p2 <- ggplot(dataA, aes(x=Sample, y=value, color=Case, group = interaction(Variable,Case))) +
geom_line(colour="black") +
geom_line(data=subset(dataA, Case == "o"), colour="green4", size=1.5)
使用color
代替fill
中的geom_area