Abdul Wahid Memon
2011-Nov-28 14:35 UTC
[R] plotting multiple lines on single graph ggplot2
Hello everyone I have some data of the following type. 100 200 300 400 500 1.1 1.2 1.3 1.4 1.5 600 700 800 900 1000 1.5 1.7 1.9 2.0 2.4 With plot() and points functions I can plot these 4 lines of data. But I dont know how to do it with qplot or ggplot functions. The scenario is something like this: the hundreds should appear on x-axis and the fractional values of y axis. Thanks alot. MEMON Abdul Wahid
There are probably lots of better aproaches but this seems to work. I just combined the lines into one vector and assighed a dummy variable to mark the diffferent lines ibrary(ggplot2) mydata <- data.frame(xrange <- c(100, 200, 300, 400, 500, 600, 700, 800, 900, 1000), yrange = c( 1.1, 1.2, 1.3, 1.4, 1.5, 1.5, 1.7, 1.9, 2.0, 2.4), mark = c(rep("a",5), rep("b", 5))) p <- ggplot(mydata, aes( xrange, yrange, colour= mark)) p <- p + geom_line() p --- On Mon, 11/28/11, Abdul Wahid Memon <engrwahidmemon at gmail.com> wrote:> From: Abdul Wahid Memon <engrwahidmemon at gmail.com> > Subject: [R] plotting multiple lines on single graph ggplot2 > To: r-help at r-project.org > Received: Monday, November 28, 2011, 9:35 AM > Hello everyone > > I have some data of the following type. > > 100 200 300 400 500 > 1.1 1.2 1.3 1.4 1.5 > 600 700 800 900 1000 > 1.5 1.7 1.9 2.0 2.4 > > With plot() and points functions I can plot these 4 lines > of data. But > I dont know how to do it with qplot or ggplot functions. > The scenario > is something like this: the hundreds should appear on > x-axis and the > fractional values of y axis. > > Thanks alot. > > MEMON Abdul Wahid > > ______________________________________________ > R-help at 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. >