[R] FIX: pscales=list(...) and splom
Jens Scheidtmann
JensScheidtmann at web.de
Sat Mar 8 15:31:48 CET 2003
Dear R Users,
When plotting with "splom" I tried to use the pscales=list(...) feature
Unfortunately it didn't work at all. Instead the scales always were
suppressed.
So I looked at the source of panel.pairs and found:
"draw <- is.numeric(pscales) && pscales != 0"
which rather has to be:
"draw <- is.list(pscales) || (is.numeric(pscales) && pscales != 0)"
With this change, the axis labels could be generated from the
supplied ...$at and ...$lab components of the pscales entries.
(BTW: the documentation says the components should be $at and $labels. This
is wrong!)
But....
* The limits of the axes are still generated from the data.
To make panel.pairs honor the ranges supplied in the pscales list, one has
to change
--snip--
if (n.var > 0) {
lim <- list(1:n.var)
for (i in 1:n.var) {
lim[[i]] <- extend.limits(range(as.numeric(z[, i]),
na.rm = TRUE))
}
}
--snap--
to
--snippi--
if (n.var > 0) {
lim <- list(1:n.var)
for (i in 1:n.var) {
lim[[i]] <- extend.limits(range(as.numeric(z[, i]),
na.rm = TRUE))
if (is.list(pscales)) {
lim[[i]] <- extend.limits(range(pscales[[i]]$at))
}
}
}
--snappi--
* The labels are still not as expected.
To fix these, occurences of "as.character(axls ..." have to be replaced by
"labels ..."
(see enclosed diff).
Now a call like the following works and displays
the correct ranges and labels:
--snippa--
# Let axes start by 0 and use other decimal separator
pscal <- list(1:4)
pscal[[1]] <- list(at=seq(0,10,2), lab=paste(seq(0,10,2)))
pscal[[2]] <- list(at=seq(0,5,1), lab=paste(seq(0,5,1)))
pscal[[3]] <- list(at=seq(0,8,2), lab=paste(seq(0,8,2)))
pscal[[4]] <- list(at=seq(0,3,0.5),
lab=format(seq(0,3,0.5),decimal.mark=","))
str(pscal)
splom(~iris[1:4], groups = Species, data = iris,
panel = panel.superpose,
key = list(title = "Three Varieties of Iris",
columns = 3,
points = list(pch = super.sym$pch[1:3],
col = super.sym$col[1:3]),
text = list(c("Setosa", "Versicolor", "Virginica"))),
pscale=pscal)
--snappa--
Please CC me on your replies, because I am not subscribed to this list.
Thanks.
HTH,
Jens
--
Jens Scheidtmann
Germany
-------------- next part --------------
A non-text attachment was scrubbed...
Name: panel.pairs.diff
Type: application/octet-stream
Size: 6777 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20030308/5bbf0a63/panel.pairs.obj
More information about the R-help
mailing list