[R] plot auto key and text into panels using lattice
Luigi Marongiu
marongiu.luigi at gmail.com
Tue Jul 21 00:38:31 CEST 2015
Dear all,
I am writing some text into several panels which I can do with this
script (in capital the variables):
xyplot(Y ~ X | Z,
data = DATAFRAME,
groups = Z,
ylab= "Y",
xlab="X",
main="TITLE",
scales = list(
x = list(draw = FALSE),
y = list(draw = FALSE),
relation="same",
alternating=TRUE),
as.table = TRUE,
layout = LAYOUT,
par.settings = list(
strip.background=list(col="white"),
axis.text = list(cex = 0.6),
par.xlab.text = list(cex = 0.75),
par.ylab.text = list(cex = 0.75),
par.main.text = list(cex = 0.8),
superpose.symbol = list(pch = ".", cex = 1)
),
strip = FALSE,
type = "l",
col = 3,
panel = function(x, y,...) {
panel.xyplot(x,y,...)
panel.text(MIN.X+(0.1*MAX.X),
MAX.Y-(0.1*MAX.Y),
labels=LABELS[panel.number()],
cex=0.3
)
}
)
A similar plot also add the autokey because it takes in account two
different Y values, but the plot is not drawn rather the function is
implemented but the plot remains empty:
xyplot(Y1+Y2 ~ X | Z,
data = DATAFRAME,
ylab= "Y",
xlab="X",
main="TITLE",
scales = list(
x = list(draw = FALSE),
y = list(draw = FALSE),
relation="same",
alternating=TRUE),
as.table = TRUE,
layout = LAYOUT,
auto.key= list(space = "centre"),
par.settings = list(
strip.background=list(col="white"),
axis.text = list(cex = 0.6),
par.xlab.text = list(cex = 0.75),
par.ylab.text = list(cex = 0.75),
par.main.text = list(cex = 0.8),
superpose.symbol = list(pch = ".", cex = 1)
),
strip = FALSE,
type = "l",
col = c(4,2),
key = list(
space="top", columns=2,
text=list(TEXT_FOR_AUTOKEY, col="black"),
lines=list(col=c(4,2)),
panel = panel.superpose
),
panel = function(x, y,...)
{
panel.xyplot(x,y,...)
panel.text(MIN.X+(0.1*MAX.X),
MAX.Y-(0.1*MAX.Y),
labels=LAB[panel.number()],
cex=0.3,
panel = panel.superpose
)
}
)
I am not attaching actual data because I believe the problem is in the
actual call, maybe I am using twice panel.superimpose, although
several combination I made (for instance moving the key argument into
the panel function) did not solve the problem.
Could you tell me where I am getting it wrong?
Thank you.
best regards
Luigi
More information about the R-help
mailing list