[R] geom_line: How to plot two data sets having different maximum X-axis values in a single plot?
John Kane
jrkrideau at inbox.com
Wed Sep 26 17:36:25 CEST 2012
Clumsy but this should do it.
aa$set <- rep("a", length(aa$position))
bb$set <- rep("b", length(bb$position))
(mydata <- rbind(aa,bb))
p <- ggplot( mydata , aes( position, count, colour = set )) + geom_line()
p
John Kane
Kingston ON Canada
> -----Original Message-----
> From: jimmikeself at gmail.com
> Sent: Tue, 25 Sep 2012 09:07:24 -0400
> To: r-help at r-project.org
> Subject: [R] geom_line: How to plot two data sets having different
> maximum X-axis values in a single plot?
>
> Hello, I just started to learn R and ggplot2. Can someone help?
>
> How to plot two data sets having different maximum X-axis values in a
> single plot?
>
> For example, I have two data sets showed below. Using position as X, and
> count as Y, how can I plot them out in different color lines within a
> single plot using ggplot2 geom_line?
>
>
>
> dataset a:
>
> position count
>
> 1 3
>
> 2 9
>
> 3 10
>
> 4 15
>
> 5 19
>
> 6 28
>
> 7 15
>
> 8 13
>
> 9 11
>
> 10 5
>
>
>
> dataset b:
>
> position count
>
> 1 4
>
> 2 8
>
> 3 16
>
> 4 17
>
> 5 19
>
> 6 10
>
>
>
> Thanks a lot!
>
>
>
>
> Jim
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
____________________________________________________________
FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!
More information about the R-help
mailing list