I have been doing other things, but want again to learn R. First some code: #try 2 axes at bottom x1 <- c(1,2,3,4,5,6,7,8,9) x2 <- c(5,1,9,6,3,7,8,2,4) plot(x1,x2,type="l") #scatter plot x1 on horizontal, x2 on vertical axis axis(1,labels=TRUE,tick=TRUE,col="red",col.axis="red",lwd=4,line=2.5) Some simple questions: 1)How do I make it put the value 1/HorizScaleValue at the lower axis ticks? 2)How do I give more space at the bottom for the lower axis? 3)How do I make the two X axes the same length? -- View this message in context: http://r.789695.n4.nabble.com/double-axis-labels-function-of-each-other-tp4705457.html Sent from the R help mailing list archive at Nabble.com.
Hi Hurr, Try this: par(mar=c(7,4,4,2)) plot(x1,x2,type="l",xlab="") require(plotrix) fullaxis(1,at=pretty(x1),labels=round(1/pretty(x1),2),tick=TRUE, col="red",col.axis="red",lwd=4,pos=-0.2) mtext("x1",side=1,line=4.5) Jim On Fri, Apr 3, 2015 at 11:16 AM, Hurr <hill0093 at umn.edu> wrote:> I have been doing other things, but want again to learn R. > First some code: > > #try 2 axes at bottom > x1 <- c(1,2,3,4,5,6,7,8,9) > x2 <- c(5,1,9,6,3,7,8,2,4) > plot(x1,x2,type="l") #scatter plot x1 on horizontal, x2 on vertical axis > axis(1,labels=TRUE,tick=TRUE,col="red",col.axis="red",lwd=4,line=2.5) > > Some simple questions: > 1)How do I make it put the value 1/HorizScaleValue at the lower axis ticks? > 2)How do I give more space at the bottom for the lower axis? > 3)How do I make the two X axes the same length? > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/double-axis-labels-function-of-each-other-tp4705457.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. >[[alternative HTML version deleted]]
Thanks, That was good help; I tried this; I hope I didn't copy it wrong: #try 2 axes at bottom x1 <- c(1,2,3,4,5,6,7,8,9) x2 <- c(5,1,9,6,3,7,8,2,4) par(mar=c(7,4,4,2)) plot(x1,x2,type="l",xlab=??) #scatter plot x1 on horiz, x2 on vert axis require(plotrix) fullaxis(1,at=pretty(x1),labels=round(1/pretty(x1),3),tick=TRUE, col=?red?,col.axis=?red?,lwd=4,pos=-0.2) mtext(?x1?,side=1,line=4.5) This is the response I got.> #try 2 axes at bottom > x1 <- c(1,2,3,4,5,6,7,8,9) > x2 <- c(5,1,9,6,3,7,8,2,4) > par(mar=c(7,4,4,2)) > plot(x1,x2,type="l",xlab=??) #scatter plot x1 on horiz, x2 on vert axisError: unexpected input in "plot(x1,x2,type="l",xlab=?"> require(plotrix) > fullaxis(1,at=pretty(x1),labels=round(1/pretty(x1),3),tick=TRUE,+ col=?red?,col.axis=?red?,lwd=4,pos=-0.2) Error: unexpected input in: "fullaxis(1,at=pretty(x1),labels=round(1/pretty(x1),3),tick=TRUE, col=?"> mtext(?x1?,side=1,line=4.5)Error: unexpected input in "mtext(?">This works but the X-axis name is not in right place: #try 2 axes at bottom x1 <- c(1,2,3,4,5,6,7,8,9) x2 <- c(5,1,9,6,3,7,8,2,4) par(mar=c(7,4,4,2)) plot(x1,x2,type="l") #scatter plot x1 on horiz, x2 on vert axis require(plotrix) fullaxis(1,at=pretty(x1),labels=round(1/pretty(x1),2),tick=TRUE, lwd=4,pos=-0.2) -- View this message in context: http://r.789695.n4.nabble.com/double-axis-labels-function-of-each-other-tp4705457p4705460.html Sent from the R help mailing list archive at Nabble.com.
Notepad should be fine but you will, I think, still have to correct the apostrophes if you are copying from Word. Any code written in Notepad should be fine. There are several dedicated editors or IDE's for use with R that you might want to look into. RStudio, Tinn-R and EMACs with ESS are some that come to mind. Among other things, they usually offer code highlighting which can be very useful for finding where there are typos, missing commas, and so on. I run Linux (Ubuntu) and find gedit with an R plug-in to be very good also. John Kane Kingston ON Canada> -----Original Message----- > From: hill0093 at umn.edu > Sent: Thu, 2 Apr 2015 23:59:17 -0700 (PDT) > To: r-help at r-project.org > Subject: Re: [R] double-axis labels function of each other > > Yes, I keep a copy in MS Word. > Would Notepad be OK? > I need sleep now, will work tomorrow. > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/double-axis-labels-function-of-each-other-tp4705457p4705463.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.____________________________________________________________ Can't remember your password? Do you need a strong and secure password? Use Password manager! It stores your passwords & protects your account.