[R] after setting auto.key=TRUE, legend become inconsistent with the graph

Mark Farnell mark.farnell at gmail.com
Tue Jun 24 05:35:21 CEST 2008

When I use xyplot (from package lattice) to produce a multi-series graph:

xyplot(linear+quadratic+sqrt~x, data=df, main="complexity of different
functions", ylab="y", col=c("red", "black", "orange"), type="b",
lty=c(1,2,3), pch=c(1,2,3), auto.key=TRUE)

where I changed the default colour, line type and data point type so
that each series is distinguishable from each other.  The graph looks
good except that the color and shape of data point of each series in
the legend still reflects the default setting of xyplot rather than
what I've said in the command!  This renders the legend useless.  So
what legend command (other than auto=TRUE) should I use instead to
solve this problem?

Also currently the legend is above the graph and below the title,
which looks weird to me and I want the legend to be placed at the
right of the graph instead.  What should I do?



More information about the R-help mailing list