Please have a look at
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
 and/or http://adv-r.had.co.nz/Reproducibility.html for some general 
suggestions on posting here. In particular have a look at dput() or do a ?dput 
in R for the best way to supply sample data.

To do the plot you want you will  need to reshape your data from “wide” format 
to “long” and then plot it with ggplot2

See ?melt in the reshape2 package for how to reshape the data.
Normally you would use the “colour” option to separately plot the two lines so 
something like should do it.

ggplot(mydata, aes( XX, value, colour = variable)) + some.plot.option.

John Kane
Kingston ON Canada


> -----Original Message-----
> From: jimmygao0...@163.com
> Sent: Tue, 15 Dec 2015 21:41:25 +0800 (CST)
> To: r-help@r-project.org
> Subject: [R] how to plot two variables in a figure using ggplot2
> 
> Hi everyone,
> 
> Now,I want to use the following data to produce a figure.But I don't know
> how to do it.Is anyone have some experiences?
> 
> X axis using variable XX and Y axis using variable OA and KA
> 
> XX OA KA
> 
> 1  1243 0.8157 0.7790
> 2  2486 0.8190 0.7829
> 3  3729 0.8278 0.7934
> 4  4972 0.8354 0.8026
> 5  6215 0.8475 0.8140
> 6  7458 0.8530 0.8224
> 7  8701 0.8668 0.8301
> 8  9944 0.8790 0.8540
> 9 11187 0.8990 0.8790
> 
> 
> Thank you very much.
> Jimmy
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>       [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

____________________________________________________________
TRY FREE IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if5
Capture screenshots, upload images, edit and send them to your friends
through IMs, post on Twitter®, Facebook®, MySpace™, LinkedIn® – FAST!

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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