willow1980
2010-Jan-10 14:45 UTC
[R] How to control spaces between axis, tick and label in xyplot or xYplot?
Dear R users, I encounter a problem regarding space control in xyplot. Basically, I want to control spaces between label, tick and axis. I remember there is a function called mgp in general plot. Is there a similar function for xyplot or xYplot? Below is my basic code: myplotkid<-xyplot(expected_offspringnumber~afr|decade,groups=SES,data1, auto.key=list(space="right"),layout=c(9,1),xlab="",ylab="Offspring number", aspect="fill",scales=list(x=list(draw=F)),strip=T) By the way, since there is no x-axis, I just want to control space parameters in y-axis. Does someone have any idea to fulfil this aim? Thank you very much for kind help! Best regards, Jianghua -- View this message in context: http://n4.nabble.com/How-to-control-spaces-between-axis-tick-and-label-in-xyplot-or-xYplot-tp1010689p1010689.html Sent from the R help mailing list archive at Nabble.com.
David Winsemius
2010-Jan-10 15:42 UTC
[R] How to control spaces between axis, tick and label in xyplot or xYplot?
On Jan 10, 2010, at 9:45 AM, willow1980 wrote:> > Dear R users, > I encounter a problem regarding space control in xyplot. Basically, > I want > to control spaces between label, tick and axis. I remember there is a > function called mgp in general plot. Is there a similar function for > xyplot > or xYplot? > Below is my basic code: > myplotkid<-xyplot(expected_offspringnumber~afr| > decade,groups=SES,data1, > auto.key=list(space="right"),layout=c(9,1),xlab="",ylab="Offspring > number", > aspect="fill",scales=list(x=list(draw=F)),strip=T) > By the way, since there is no x-axis, I just want to control space > parameters in y-axis. Does someone have any idea to fulfil this aim?Had you included a dataset that was executable, this might have been tested, but as it is I will only offer a hack that I have used in the past with y-labels in xYplot. My memory is that there are about 3 line- widths of space and that the y-labels are at the leftmost position by default. I have in the past moved the labels to the right with leading"\n"'s. The help page for xyplot indicates that finer control of xlab and ylab can be accomplished via methods described in the section regarding main, and there we find these ideas: "Further named arguments are passed on to textGrob; this can include arguments controlling positioning like just and rot as well as graphical parameters such as col and font (see gpar for a full list)."> Thank you very much for kind help! > Best regards, > Jianghua > --David Winsemius, MD Heritage Laboratories West Hartford, CT
Peter Ehlers
2010-Jan-10 21:26 UTC
[R] How to control spaces between axis, tick and label in xyplot or xYplot?
You don't provide reproducible code and your space bar seems to be broken (or perhaps, you're trying to save bandwidth by minimizing the number of characters sent), but this may be what you're after: myspacing <- 0.5 xyplot(Sepal.Length ~ Petal.Length | Species, data = iris, layout = c(3,1), par.settings = list(layout.widths = list(ylab.axis.padding = myspacing))) Fiddle with myspacing until you're satisfied. BTW, you probably don't need 'aspect = "fill"' since that's the default (unless you've reset that in global lattice options). -Peter Ehlers willow1980 wrote:> Dear R users, > I encounter a problem regarding space control in xyplot. Basically, I want > to control spaces between label, tick and axis. I remember there is a > function called mgp in general plot. Is there a similar function for xyplot > or xYplot? > Below is my basic code: > myplotkid<-xyplot(expected_offspringnumber~afr|decade,groups=SES,data1, > auto.key=list(space="right"),layout=c(9,1),xlab="",ylab="Offspring number", > aspect="fill",scales=list(x=list(draw=F)),strip=T) > By the way, since there is no x-axis, I just want to control space > parameters in y-axis. Does someone have any idea to fulfil this aim? > Thank you very much for kind help! > Best regards, > Jianghua-- Peter Ehlers University of Calgary 403.202.3921
willow1980
2010-Jan-11 16:25 UTC
[R] How to control spaces between axis, tick and label in xyplot or xYplot?
Thanks a lot for your help! I have tried Peter's code: it works perfectly. Hopefully, this method will also be helpful to others with similar problems. Best regards, Jianghua -- View this message in context: http://n4.nabble.com/How-to-control-spaces-between-axis-tick-and-label-in-xyplot-or-xYplot-tp1010689p1011340.html Sent from the R help mailing list archive at Nabble.com.
Reasonably Related Threads
- How to control number of significant digits (figures) in y-axis?
- Why there is no p-value from likelihood ratio test using anova in GAM model fitting?
- How to plot 3-D surface graph from lmer mixed models?
- xyplot, the first tick mark starts from 2 rather than 1, and also there is a NA as the final tick mark.
- Calculating the percentage of explained deviance in lmer