Place all axis labels left and bottom in the R-lattice xyplot
I would like to change the default xyplot setting where the label labels alternate in the panel.
xyplot(yield~N | P+K, data=npk)
I understand that deliberately avoiding extreme overlap in adjacent panels, but for the categorical x-axis labels as shown above, this is optional and looks strange to post.
Is there a way to put all axis labels on the same side as shown below (which I edited in a graphics program)?
source to share
Making sure I didn't duplicate the question, I tried a few new searches and found a solution embedded in the long xyplot help file.
There is a parameter called "scales" which itself contains many parameters that you can specify, and it should be in the list. The default value for alternating
is TRUE
, and switching it to FALSE
will do the trick:
xyplot(yield~N | P+K, data=npk, scales=list(alternating=FALSE))
You can also enter a numeric value for this parameter to determine which side these labels should continue on:
xyplot(yield~N | P+K, data=npk, scales=list(alternating=1))
xyplot(yield~N | P+K, data=npk, scales=list(alternating=2))
You can pass several parameters to it to make each panel behave differently:
xyplot(yield~N | P+K, data=npk, scales=list(alternating=c(1,0)))
The default is here c(1,2)
source to share