[R] fill prob. in legend

Martin Maechler maechler at stat.math.ethz.ch
Tue Feb 25 10:13:02 CET 2003


>>>>> "Jerome" == Jerome Asselin <jerome at hivnet.ubc.ca>
>>>>>     on Mon, 24 Feb 2003 10:49:38 -0800 writes:

    Jerome> Ok... All we need is an "blank" symbol (such as pch=30(?)).

no, that's "currently undefined".  Rather use NA

    Jerome> Now try again...

    Jerome> Jerome

    Jerome> plot(0,0)
    Jerome> legend(0,0,c("blah","blahblah","blahblahblah","blah..."),
    Jerome> pch=c(30,30,22,22),
    Jerome> col=c("green","red","blue","blue"),
    Jerome> lty=c(1,1,2,2),
    Jerome> pt.bg=c("white","white","yellow","orange"),cex=2)

well done!  Using NA instead, twice, (and indenting) gives

plot(0,0)
legend(0,0,c("blah","blahblah","blahblahblah","blah..."),
       pch=c(NA,NA,22,22),
       col=c("green","red","blue","blue"),
       lty=c(1,1,2,2),
       pt.bg=c(NA,NA,"yellow","orange"), cex=2)


    Jerome> On Monday 24 February 2003 10:34, Uwe Ligges wrote:
    >> Content-Length: 1182
    >> Status: R
    >> X-Status: N
    >> 
    >> Jerome Asselin wrote:
    >> > I think this does what you want...
    >> >
    >> > Jerome
    >> >
    >> > plot(0,0)
    >> > legend(0,0,c("blah","blahblah","blahblahblah","blah..."),
    >> > pch=c(21,21,22,22),
    >> > col=c("green","red","blue","blue"),
    >> > pt.bg=c("white","white","yellow","orange"),cex=2)
    >> 
    >> I don't think so, because Jeremy Butler asked for *lines*.
    >> Unfortunately, the my answer won't be much more helpful (see below).
    >> 
    >> > On Sunday 23 February 2003 17:29, Jeremy Z Butler wrote:
    >> > > Hi,
    >> > > I'm trying to construct a legend which has four lines of text and
    >> > > associated symbols. The first two symbols need to be normal lines which
    >> > > vary only in colour. The second two symbols should have filled boxes.
    >> > > How do I suppress the fill boxes in the first two lines?
    >> > > J.
    >> 
    >> Well, you cannot, AFAIK.
    >> You have to construct such a special legend using either two tricky
    >> calls to legend, or add the elements with low level functions like
    >> text() and friends to the plot.
    >> I think a contribution of an improvement of legend() that solves your
    >> problem is welcome.
    >> 
    >> Uwe Ligges
    >> 
    >> ______________________________________________
    >> R-help at stat.math.ethz.ch mailing list
    >> http://www.stat.math.ethz.ch/mailman/listinfo/r-help

    Jerome> -- 

    Jerome> Jerome Asselin (Jérôme)
    Jerome> Statistical Analyst
    Jerome> British Columbia Centre for Excellence in HIV/AIDS
    Jerome> St. Paul's Hospital
    Jerome> 608 - 1081 Burrard Street
    Jerome> Vancouver, British Columbia
    Jerome> CANADA V6Z 1Y6

    Jerome> Email: jerome at hivnet.ubc.ca
    Jerome> Phone: 604 806-9112   Fax: 604 806-9044

    Jerome> ______________________________________________
    Jerome> R-help at stat.math.ethz.ch mailing list
    Jerome> http://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list