How to plot two dataset in point and line form in one figure in R?
I have two dataset (each has two columns of data). 开发者_Go百科 I want to use R to xyplot both dataset into one figure, while one is in point form, one is in smooth line format.
Could you mind to teach me how to do so? thanks.
In general:
plot(first_dataset, type="p")
par (new=TRUE)
plot(second_dataset)
You have several options:
1) Use plot
with the "o" (overplot) type
plot (x, y, t="o")
2) In general, as @Milktrader said, you can call plot twice with new=TRUE
, for instance:
plot (x, y)
plot (x, y, "l", new=T)
3) Use points
plot (x, y)
points (x, y, "l")
4) Split the screen with split.screen
or layout
split.screen(c(1,2))
screen(1)
plot(x, y)
screen(2)
plot(x, y, "l")
And there are surely many others...
精彩评论