[R] Color of box frame in Legend (Was: Matrix barplot)
Andreas Tille
tillea at rki.de
Mon Jul 28 10:51:38 CEST 2008
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
More information about the R-help
mailing list