On Thu, Feb 25, 2010 at 1:24 AM, Marcin Kozak <nyg...@gmail.com> wrote:
> Dear all,
>
> Considering this simple example of hexbinplot:
> mixdata <-
>     data.frame(x = c(rnorm(5000), rnorm(5000,4,1.5)),
>                y = c(rnorm(5000), rnorm(5000,2,3)),
>                a = gl(2, 5000))
> fig <- hexbinplot(y ~ x | a, mixdata)
> print(fig)
> update(fig, colramp = BTC)
>
> produces a bad (non-updated) legend. Compare it with:
>
> hexbinplot(y ~ x | a, mixdata, colramp = BTC)
>
> What should I do to update the plot with the correct legend?

Why not just use

hexbinplot(y ~ x | a, mixdata, colramp = BTC)

? In this (relatively simple) case, you could do

fig2 <- update(fig, colramp = BTC)
fig2$legend$right$args$colramp <- BTC
fig2

It should be possible to write an update method for hexbinplots to do
that automatically, but that doesn't happen currently (and I'm not
sure if it's worth the effort).

In general, an implicit assumption of the Trellis design is that the
panel display is independent of the legend. A much simpler example:

p <- xyplot(1:10 ~ 1:10, groups = gl(2, 5), auto.key = TRUE)
p
update(p, col = c("red", "blue"))

The simplest working solution in this case would be

update(p, par.settings = simpleTheme(col = c("red", "blue")))

but that actually involves several layers of patches on the original
design in S-PLUS (in particular, it actually changes the default
colors used by both panel and legend).

-Deepayan

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to