jpm miao
2013-Apr-10 01:24 UTC
[R] Plot two separate curves in R Graphics and R Lattice package
Hi, How can I plot two curves with distinct x and y vectors? I would like to join one of them by regular lines and plot the other just by points (no lines). Can it be done in regular R graphic tools, say "plot" function? Can it be done in Lattice package, say "xyplot" function? Thanks, Miao My data look like this: two curves with different vector size x y 3973730 0.00322 2391576 0.003487 2840944 0.005145 2040943 0.006359 1982715 0.006253 1618162 0.00544 820082.3 0.004213 1658597 0.004883 1762794 0.006216 93439.5 0.004255 218481.3 0.006924 2332477 0.004862 725835.5 0.00089 811575.3 0.012962 292223 0.002614 153862.3 0.007524 1272367 0.006899 734199 0.00988 421404.5 0.005048 189047.5 0.004821 529102 0.009637 56833 0.006171 125856.3 0.00839 598893.8 0.006622 258240 0.00613 159086.3 0.008819 122863 0.010093 404699.5 0.008148 453514.5 0.008407 545028 0.006096 1233366 0.006111 1192758 0.008162 147563.3 0.00838 247293 0.010283 1074838 0.007413 459227.5 0.00862 202332 0.009061 377401.3 0.006923 1876753 0.010226 and x y 50118.72 0.012117 51286.14 0.012054 52480.75 0.011991 53703.18 0.011928 54954.09 0.011865 56234.13 0.011803 57543.99 0.011742 58884.37 0.01168 60255.96 0.011619 61659.5 0.011559 63095.73 0.011498 64565.42 0.011438 66069.34 0.011379 67608.3 0.011319 69183.1 0.01126 [[alternative HTML version deleted]]
Janesh Devkota
2013-Apr-10 01:38 UTC
[R] Plot two separate curves in R Graphics and R Lattice package
Hi, This should be fairly easy by using base R graphics. Lets suppose your first data is represented by (x1,y1) and second data is represented by (x2,y2) You can use the following command. plot(x1,y1,type="l") points(x2,y2) Hope it helps. On Tue, Apr 9, 2013 at 8:24 PM, jpm miao <miaojpm@gmail.com> wrote:> Hi, > > How can I plot two curves with distinct x and y vectors? I would like to > join one of them by regular lines and plot the other just by points (no > lines). Can it be done in regular R graphic tools, say "plot" function? > Can it be done in Lattice package, say "xyplot" function? > > Thanks, > > Miao > > My data look like this: two curves with different vector size > > x y > 3973730 0.00322 2391576 0.003487 2840944 0.005145 2040943 0.006359 > 1982715 0.006253 1618162 0.00544 820082.3 0.004213 1658597 0.004883 > 1762794 0.006216 93439.5 0.004255 218481.3 0.006924 2332477 0.004862 > 725835.5 0.00089 811575.3 0.012962 292223 0.002614 153862.3 0.007524 > 1272367 0.006899 734199 0.00988 421404.5 0.005048 189047.5 0.004821 > 529102 0.009637 56833 0.006171 125856.3 0.00839 598893.8 0.006622 > 258240 > 0.00613 159086.3 0.008819 122863 0.010093 404699.5 0.008148 453514.5 > 0.008407 545028 0.006096 1233366 0.006111 1192758 0.008162 147563.3 > 0.00838 247293 0.010283 1074838 0.007413 459227.5 0.00862 202332 > 0.009061 377401.3 0.006923 1876753 0.010226 > and > x y > 50118.72 0.012117 51286.14 0.012054 52480.75 0.011991 53703.18 0.011928 > 54954.09 0.011865 56234.13 0.011803 57543.99 0.011742 58884.37 0.01168 > 60255.96 0.011619 61659.5 0.011559 63095.73 0.011498 64565.42 0.011438 > 66069.34 0.011379 67608.3 0.011319 69183.1 0.01126 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]