plot 2 y axis
On 04/17/2013 08:35 AM, Ye Lin wrote:
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.
Hi Ye lin, Try this (yldat is your data above as a data frame): library(plotrix) twoord.plot(yldat$Date,yldat$Height,yldat$Weight, lylim=c(0,1.04),rylim=c(0,0.61), xtickpos=1:4,xticklab=1:4) That should get you started. Jim