I would like to alter the default xyplot setting where the axis labels alternate by panel.
xyplot(yield~N | P+K, data=npk)
I realize that it is intentional to avoid overlaps of axis extremes on neighboring panels, but for categorical x-axis labels as shown above, it is not necessary and looks odd for publication.
Is there a way to put all axis labels on the same side as shown below (which I edited in a graphics program)?
While checking to make sure I didn't duplicate a question, I tried some new search terms and found the solution buried in the lengthy xyplot help file.
There is a parameter called “scales” that itself has a bunch of parameters that you can specify, and it has to be in a list. The default 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 what side the labels should go 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 it multiple parameters to have each panel behave differently:
xyplot(yield~N | P+K, data=npk, scales=list(alternating=c(1,0)))
Default here is c(1,2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With