[R] axis label config mgp

Greg Snow Greg.Snow at imail.org
Thu Jul 16 18:00:32 CEST 2009


Leave the mgp setting alone and use xlab='' when you create the original plot.  This will put the y-label in the usual place and not create the x-label.  Then use the "title" or "mtext" function to place the x label where you want it.

Hope this helps, 

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Marlin Keith Cox
> Sent: Wednesday, July 15, 2009 6:41 PM
> To: r-help at r-project.org
> Subject: [R] axis label config mgp
> 
> I have long axis labels (8units) on the x axis and 2 unit number labels
> on
> the y axis.  I need to move the x axis title without moving the y axis
> title.  I have used mgp=c(title, label and line), but mgp moves both
> the x
> and y titles.  The following puts the y axis title way way out to the
> left.
> Anyone know how to move just the x axis.
> X11()
> conif<-c("Control", "Switched Wires", "Salt", "Conductive Board",
> "Needle
> Size", "Needle Depth")
> par(family="serif", cex=1.2)
> par(mfrow=c(1,2),lab=c(length(conif),4,4),mar=c(16.1,10.1,4.1,2.1),
> mgp=c(10,1,0))
> boxplotR<-boxplot(R ~ Trt, xlab="Configuration",ylab="Resistance
> (Ohms)",
> xaxt='n', cex.axis=1.6,cex.lab=1.6)
> axis(side=1, at=c(1,2,3,4,5,6), labels=conif, las=2, cex.axis=1.4)
> --
> 
> kc
> 
> 
> Keith Cox, Ph.D.
> Alaska NOAA Fisheries, National Marine Fisheries Service
> P.O. Box 464
> Sitka, Alaska, 99835
> 
> 907 752-0563
> marlinkcox at gmail.com
> 
> 	[[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.




More information about the R-help mailing list