3

同じ間隔で取得された 3 つのタイムスタンプ付き測定シリーズがありますが、実際のタイムスタンプは異なります。この 3 つの軌跡をまとめて表示したいのですが、x 軸 (タイムスタンプ) がそれぞれ違うので困っています。使用する x 軸を選択せず​​に、他の 2 つの測定系列の y 値を補間せずにこれを行う方法はありますか? 私はRにかなり慣れていませんが、見落としている明らかな何かがあるように感じます。

例えば:

シリーズ 1

Time    Value
1.023   5.786
2.564   10.675
3.678   14.678
5.023   17.456

シリーズ 2

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
4

4 に答える 4

5

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"))

?legend凡例を追加するには、 を参照してください。または、学習ggplot2して、その部分を処理させます。

library(ggplot2)
library(reshape)
plotdata <- melt(list(dat1 = dat1, dat2 = dat2, dat3 = dat3), "Time")

qplot(Time, value, data = plotdata, colour = L1)
于 2011-05-24T19:56:21.203 に答える
3

これを試して:

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")

ここに画像の説明を入力

于 2011-05-24T20:12:44.003 に答える
1

これ以上の情報がなければ、:pointsとの組み合わせを使用する必要があるようですxlim
を使用して点(または線)の単一の組み合わせをプロットしplot、引数を渡して、xlimすべての時間入力がプロットに収まるようにします。
次に、pointsまたはを使用して他のデータをプロットに追加し、出力を区別するためにこれらの関数にもパラメーターをlines渡すことができます。 最小限の再現可能な例を含めると、詳細を提供できます。color

于 2011-05-24T19:47:12.027 に答える
0

各系列の時間の最小値を引きます。3 つの結果の最大値を xlim[2] として決定します。ラベル抑制を使用して matplot を使用してプロットし、labels= と at= を axis() で追加します。

于 2011-05-24T20:04:30.700 に答える