【发布时间】:2016-05-25 09:50:09
【问题描述】:
当我在同一个图表中绘制 2 个数据框时,我无法获得相同的原点 这是我的数据样本:
spec_sum <- data.frame(x = c("2015-01-08","2015-01-13","2015-01-14","2015-01-15","2015-01-15","2015-01-19","2015-01-19","2015-01-21","2015-01-21","2015-01-27"),y = c(1, 1, 1, -1, -1, 1, 1, 1, 1, 1))
odtgen_sum <- data.frame(x = c("2015-01-12","2015-01-14","2015-01-15","2015-01-26","2015-01-27","2015-01-29","2015-01-30","2015-01-30","2015-02-04","2015-02-04"),y=c(1,-1,1,1,1,1,-1,-1,-1,1))
这是我的 ggplot 代码:
library(reshape)
newData <- melt(list(spec_sum = spec_sum, odtgen_sum = odtgen_sum),
id.vars = "x")
#Specify colour vector
cols <- c("blue", "red", "green", "orange")
ggplot(newData, aes(x, cumsum(value), colour = L1)) +
geom_line() + xlab("Date") + ylab("Nb depeches dev") +
scale_colour_manual(values = cols) + theme_bw() +
theme(legend.justification=c(0,0), legend.position=c(0.8,0))
【问题讨论】:
-
结果应该是什么样子?
-
我的问题是我的 2 行之间有一个偏移量,我不知道如何删除这个偏移量。
-
通常情况下,两条线应该在计数轴(累积)上大致相同的水平开始,但我有一个偏移量