为什么r(r代码)在我的图表中给出了锯齿线?

问题描述 投票:0回答:1
LocA<-(Graphdata[["Loc==AB"]])
plot(0, 0, xlim = c(1, 20), ylim = c(70, 200), asp=NA, xlab = "", ylab = "", type = "n")
lines(LocA$K,type="l",col="blue",lwd=2)
lines(LocA$L,type="l",col="green",lwd=2)
lines(LocA$M,type="l",col="red",lwd=2)
lines(LocA$N,type="l",col="orange",lwd=2)

我希望x =轴覆盖1:20的范围,因为它是由xlim = C(1:20)给出的,但它没有扩展到该范围,图形看起来很堵塞,并且它不会超过10但它应该涵盖D.enter image description here给出的范围部分数据,这些数据的图表如下:

    Loc D     K        L           M           N
1   AB  1  95.03813   110.4466        NA       NA
2   AB  3  82.36166   154.3045        NA       NA
3   AB  5  81.08041   118.5903        NA       NA
4   AB  7  82.40850   110.6272    87.89905       NA
5   AB  9  83.94922   105.1753        NA      82.28767
6   AB 11  84.94135   102.8754        NA      77.83648
7   AB 13  85.835855  101.209326  80.077513   75.355855 
8   AB 15  86.309016  100.978860  79.784663   75.128083 
9   AB 17  87.792539  99.914197  78.878135    75.121244
r graphing
1个回答
0
投票

正如zacdav的评论所指出的那样,你忘了为你的行指定自变量x值。

例如,你写的地方:

lines(LocA$K,type="l",col="blue",lwd=2)

你应该添加LocA$D,像这样:

lines(LocA$D, LocA$K,type="l",col="blue",lwd=2)

对于每个行定义。

© www.soinside.com 2019 - 2024. All rights reserved.