[R] plot 2 y axis
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
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
> 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
> 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"
> the right y axis.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> 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