Hello,
I'm attempting to alter the location of text in my axis labels in lattice
plots and have been unsuccessful so far. ?For example, the y-axis labels are
always right-justified, but I would like them to be horizontally centered.
Here's an example:
library(lattice);
# create fake dataset to plot
to.plot <- data.frame(
? ? ? ?x = 1:5,
? ? ? ?y = c("1\nAAA", "2\nBBB", "3\nCCC", "4\nDDD", "5\nEEE")
? ? ? ?);
# initial plot, note that the y-axis labels are right-justified
xyplot(
? ? ? ?y ~ x,
? ? ? ?to.plot,
? ? ? ?pch = 19,
? ? ? ?ylab = "",
? ? ? ?xlab = "",
? ? ? ?cex = 3
? ? ? ?);
# now try to set the positioning via scales
xyplot(
? ? ? ?y ~ x,
? ? ? ?to.plot,
? ? ? ?pch = 19,
? ? ? ?ylab = "",
? ? ? ?xlab = "",
? ? ? ?cex = 3,
? ? ? ?scales = list(
? ? ? ? ? ? ? ?labels = to.plot$y,
? ? ? ? ? ? ? ?hjust = 0.5,
? ? ? ? ? ? ? ?vjust = 0.5
? ? ? ? ? ? ? ?)
? ? ? ?);
I also explored using yscale.components.default(), but specifying hjust and
vjust there did not help. ?Any suggestions would be very much appreciated!