On Apr 10, 2013, at 12:44 AM, jpm miao wrote:

Hi David,

   Many thanks. I try to follow your example and code as follows:

xyplot( avg_cost_2012 ~ asset_2012,
          panel=function(x,y) {
          panel.xyplot(x,y, type="p")
panel.lines(x2, y1, col="red")},scales=list(x=list(log=10)))

However, I do see the points "p" of "avg_cost_2012 ~ asset_2012", but do not see the line for y1 against x2. y1 and x1 are numeric vectors of the same size. How can I fix it?

Without seeing the data it is difficult to enumerate the possible errors you could be making.

I say again:

Your example was not presented in a form that lent itself to easy editing. Please learn to use dput to present data structures.

-- David



Thnaks

Miao


2013/4/10 David Winsemius <dwinsem...@comcast.net>

On Apr 9, 2013, at 8:21 PM, jpm miao wrote:

Thank you very much.

Could it be done in Lattice package?



Your example was not presented in a form that lent itself to easy editing. Please learn to use dput to present data structures:

xyplot( 4:6 ~ 1:3,
       panel=function(x,y) {
                panel.xyplot(x,y, type="l")
panel.points(x=c(1.1, 2.1), y=c(4.1, 5.1), col="red") } )

--
David.


Thanks,

Miao


2013/4/10 Janesh Devkota <janesh.devk...@gmail.com>

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 <miao...@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
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Alameda, CA, USA



David Winsemius, MD
Alameda, CA, USA

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to