如何为三个相似的时间/值图使用公共轴

|| 我有三个带时间戳的测量系列,在相同的时间间隔内进行,但具有不同的实际时间戳记。我想在组合图中显示这三个轨迹,但是由于x轴(时间戳)在每种情况下都不相同,因此我遇到了一些麻烦。有没有一种方法可以这样做,而无需选择使用x轴并为其他两个测量系列插入y值?我对R相当陌生,但是我感觉有些明显的东西我正在忽略。 例如: 系列一
Time    Value
1.023   5.786
2.564   10.675
3.678   14.678
5.023   17.456
系列二
0.787   1.765
1.567   3.456
3.011   5.879
4.598   7.768
系列3
1.208   3.780
2.478   6.890
3.823   9.091
5.125   12.769
    
已邀请:
对于基本图形,可以结合使用
plot
points
lines
dat1 <- data.frame(Time = c(1.023, 2.564, 3.678, 5.023), Value = c(5.786, 10.675, 14.678, 17.456))
dat2 <- data.frame(Time = c(0.787, 1.567, 3.011, 4.598), Value = c(1.765, 3.456, 5.879, 7.768))
dat3 <- data.frame(Time = c(1.208, 2.478, 3.823, 5.125), Value = c(3.780, 6.890, 9.091, 12.769))

with(dat1, plot(Time, Value, xlim = c(0,6), ylim = c(0,20)))
with(dat2, points(Time, Value, col = \"red\"))
with(dat3, points(Time, Value, col = \"green\"))
看一下ѭ7来添加图例。或者,学习
ggplot2
并让它为您处理该部分内容:
library(ggplot2)
library(reshape)
plotdata <- melt(list(dat1 = dat1, dat2 = dat2, dat3 = dat3), \"Time\")

qplot(Time, value, data = plotdata, colour = L1)
    
尝试这个:
t1 <- \"Time Value
1.023   5.786
2.564   10.675
3.678   14.678
5.023   17.456\"

t2 <- \"Time Value
0.787   1.765
1.567   3.456
3.011   5.879
4.598   7.768\"

t3 <- \"Time Value
1.208   3.780
2.478   6.890
3.823   9.091
5.125   12.769\"

tex1 <- read.table(textConnection(t1), header = TRUE)
tex2 <- read.table(textConnection(t2), header = TRUE)
tex3 <- read.table(textConnection(t3), header = TRUE)

plot(tex1, type=\"l\", xlim=range(tex1$Time, tex2$Time, tex3$Time), ylim=range(tex1$Value, tex2$Value, tex3$Value), main=\"Common Time Axis for 3 Data Series\", col=\"black\")
grid()
lines(tex2, col=\"red\")
lines(tex3, col=\"blue\")
    
没有更多的信息,您似乎将不得不使用:4ѭ和
xlim
的组合。 使用
plot
绘制点(或线)的单个组合,并传递
xlim
参数,以便您所有的时间输入都可适合该图。 然后,使用
points
lines
将其他数据添加到绘图中,还可以将functions17ѭ参数传递给这些函数以区分输出。 如果您提供了一个最小的可复制示例,我们将提供更多详细信息!     
减去每个系列中时间的最小值。确定三个结果中的最大值作为xlim [2]。使用带有标签抑制的matplot进行绘图,然后使用axis()添加label =和at =。     

要回复问题请先登录注册