Re: [R] Color of box frame in Legend (Was: Matrix barplot)

From: Andreas Tille <tillea_at_rki.de>
Date: Mon, 28 Jul 2008 10:51:38 +0200 (CEST)

On Sun, 27 Jul 2008, S Ellison wrote:

> Looking at the legend() source the filled box line colour is hardcoded :
> if (mfill) {
> if (plot) {
> fill <- rep(fill, length.out = n.leg)
> rect2(left = xt, top = yt + ybox/2, dx = xbox, dy = ybox,
> col = fill, density = density, angle = angle,
> border = "black")
> }
> xt <- xt + dx.fill
> }
>
> ... so it looks like you can have any colour as long as it's black.
>
> However, you could copy the legend code (type legend<CR> to see it, then
> paste it into a text editor, modify the "black" to, say, par("fg") or
> even add your own extra parameter to the function, then just paste the
> function back into your own version.

Unfortunately this does not work. I even tried to rename "legend" to "mylegend" to make sure that my changed version is really used. If I do so I get

    Error: could not find function "mylegend"

which explains why the changed function legend seems not to be used - the function definition just pasted in the R script before I call the legend function is ignored.

Despite the fact that this does not work I'm looking for a simple way to put the new definition in an extra file that is just included by my R - scripts (I have more than one). I'm thinking of a similar thing like "\input" for TeX or "#include" for C or something like that to store the hack in a separate file.

Kind regards

          Andreas.

-- 
http://fam-tille.de

______________________________________________
R-help_at_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.
Received on Mon 28 Jul 2008 - 08:56:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 28 Jul 2008 - 13:32:38 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive