So far, I have not received any replies to my original message. I did some
exploring on my own. Here's what I've found.
1) It should have been obvious to me that pch=c('A',8) would be the same as
pch=c('A','8') since the vector c('A',8) will be coerced to a character
vector.
2) I explored the key() function and determined how it uses the
points=list(....) supplied in the trellis plotting function. Points, lines,
text, and rectangles are placed in the legend by use of the low-level
graphics functions points(), lines(), text() and polygon(). For the legend
symbol, the vector passed with pch= is used in the points() or lines()
functions. If passed in a numeric vector, then this will cause the symbols
to be placed in the legend. If passed in a character vector, the first
character of each string is placed in the legend. In the legend() function,
these two types of legend 'symbols' were declared by use of marks= and pch=,
respectively for symbols or characters. The key function does not, as far
as I could tell, encompass two such vectors.
3) To get the desired result, I made a copy of the key function, and edited
a few (5) lines so that it allowed passing both pch= and marks= vectors in
the trellis plotting function call. In this respect, it behaves similar to
the legend() function. However, I had to mask the standard key() function
with my revised version to get it implemented. This was because I could not
determine a way to have my.key() used instead of key().
I'd like to know if others have a suggestion for obtaining the desired
results without masking the key() function.
Thanks in advance.
Jim Pratt
jamesp@mocr.oapi.com
> -----Original Message-----
> From: Pratt, James [SMTP:jamesp@mocr.oapi.com]
> Sent: Wednesday, January 20, 1999 4:40 PM
> To: 's-news@wubios.wustl.edu'
> Subject: [S]: mixing character and symbols in key
>
>
> I am using S+ 4.5 in Win/NT environment. Have created trellis plot with
> two
> 'symbol' types. One with pch="|" to get a vertical line at the point.
> The
> other using pch=8, to get the asterisk symbol. I'm trying to add a legend
> to the multipanel display using key().
>
> +
> key=list(space="bottom",points=list(pch=c("|","*"),col=c(2,5),cex=c(1,1.5)
> ,f
> ont=c(1,2)),
> + text=c("Estimated Mean","Raw Mean"),x=.1,y=-.1))
>
> The problem is that the legend '*' does not look like the plotted
> asterisk.
> Also the legend asterisk is slightly raised (like a superscript), not
> centered with its associated text string.
>
> I looked through the statlib index and found a solution to doing this via
> legend (dated Sept 1991; see at end of message). I am wondering how to
> duplicate the solution with key(). I tried the following
>
>
> + key=list(space="bottom",points=list(pch=c("|","\
> "),marks=c(-1,8),col=c(2,5),cex=c(1,1.5),
> + font=c(1,2)),text=c("Estimated Mean","Raw Mean"),x=.1,y=-.1))
>
> It left a blank in space where the asterisk was to appear. I do not see
> marks as a parameter in key(), so perhaps that aspect got lost. I also
> tried pch=("|",8) but the numeral "8" appeared in the legend not the
> desired
> asterisk.
>
> So, how, if possible, to get characters and symbols to appear in a legend
> when using the key() function?
>
> Thanks.
>
> Jim Pratt
> jamesp@mocr.oapi.com
>
> -----From Statlib ----------
> Subject: Re: Squares (pch=0) in legends
> Date: Fri, 13 Sep 91 15:54:32 -0700
> ------Original message--------
> The problem of displaying the pch=0 symbol as part of a legend is a bug
> that
> was fixed in the August 1991 release of S.
> Occasionally I want to produce a legend line that has no symbol, and I
> have
> been accomplishing this using pch=0. For example, the following legend
> command
> >legend(3,4.3,c("Age at Time of Study", "", "All Ages", "10 or under", "5
> or
> under"),marks=c(0,0,1,2,3))
> produces a legend that looks something like this:
> Age at Time of Study
> 0 All Ages
> * 10 or under
> + 5 or under
> If the "pch=0" bug has been fixed, how can I generate such legends?
> -----end of Original message
> -----Reply from Patrick Burns
> I'm not sure about ATT S but in version 3.0 of S-PLUS (based on the August
> 91 release), you will be able to do the following:
> >legend(..., legend=c("this is for blanks", "this is squares",
> >"this is A"), pch="\ A",marks=c(-1,0,-1))
>
> The `pch' string is four typed characters: backslash,<space> ,<sapace> ,
> A.
> The backslash-space in `pch' says don't put anything here, as does -1 in
> `marks'.
> Patrick Burns pat@statsci.com
>
>
> -----------------------------------------------------------------------
> This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
> send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
> message: unsubscribe s-news
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|