[R] plot 2 y axis
John Kane
jrkrideau at inbox.com
Wed Apr 17 16:56:51 CEST 2013
Exel is hardly the epitome of good graphing. There are a couple of ways to do what you want and Jim has shown you one , but ...
What about using two panels to present the data as in
opar <- par(mfrow = c(2, 1))
plot(dat1$Date, dat1$Weight, col = "red", xlab = "", ylab = "Weight")
plot(dat1$Date, dat1$Height, col = "blue", xlab = "Date", ylab = "Height")
par <- opar
John Kane
Kingston ON Canada
> -----Original Message-----
> From: yelin at lbl.gov
> Sent: Tue, 16 Apr 2013 15:35:29 -0700
> To: r-help at r-project.org
> Subject: [R] plot 2 y axis
>
> Hi,
>
> I want to plot two variables on the same graph but with two y axis just
> like what you can do in Excel. I searched online that seems like you can
> not achieve that in ggplot. So is there anyway I can do it in a nice way
> in
> basic plot?
>
> Suppose my data looks like this:
>
> Weight Height Date
> 0.1 0.3 1
> 0.2 0.4 2
> 0.3 0.8 3
> 0.6 1 4
>
> I want to have"Date"as X axis ,"Weight" as the left y axis and "Height"
> as
> the right y axis.
>
> Thanks.
>
> [[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