[R] Symbols for male/female
Robert Cunningham
robut at forest.go.th
Thu Oct 31 13:10:31 CET 2002
G'day,
Perhaps this is all that is needed
> x <- rnorm(10)
> plot(x,y,pch=4)
> text(x,y,"\\MA",vfont=c("sans serif symbol","plain"),cex=2)
A few problems:
-A cex too large starts to show the "gaps"
-Perhaps the symbols are not quite centered the way you want-that could
be 'adjusted'
-Filled symbols would need to be made with a carefully 'adjusted' pch=20
These adjustments could be done in a reusable function.
The \\MA comes from Mars and \\VE is the female equivalent, see more
details in:
?Hershey
Cheers,
Robert Cunningham
Lorenz Gygax writes:
>
> Dear all,
>
> I would like to use the biological symbols for male and female as plotting
> symbols in a scatterplot (ideally filled and non-filled). R does not seem
> to have these symbols using pch= in plot() nor are they implemented via
> expression() or at least I did not find them. I found that the symbols are
> e.g. available in the wasysym and the marvosym package in LaTeX.
>
> I have coded two very rough functions that are able to approximate those
> symbols, but not surprisingly, they are not very efficient regarding the
> file size they produce (I have included the code for the female symbol at
> the end of the mail).
>
> Is there a more or less straightforward way to implement these symbols so
> that they can be accessed either by pch= or expression()? Can you give me
> some pointers on how I would need to go about this?
>
> Thanks and regards, Lorenz
> --
> Lorenz Gygax, Dr. sc. nat.
> Artificial Intelligence Lab, Department of Information Technology
> University of Zurich-Irchel, +41-1-635 67 17, gygax at ifi.unizh.ch
>
>
> one.female <- function (X, diam= 1, prop= 1, lw= 1) {
> ## X a vector giving the position of the symbol c (x, y)
> ## diam: diameter in the entities on the Y axis
> ## prop: proportion of x to y axis (so that symbols will be round
> ## lw: adjustment of line width for large symbols
>
> x.ring <- cos (seq (0, 2*pi, len= 500)) * prop * diam/2
> y.ring <- sin (seq (0, 2*pi, len= 500)) * diam/2
> lines (x.ring + X[1], y.ring + X[2], lwd= lw)
> segments (c (0, -diam/4) + X[1],
> c (-diam/2, -3*diam/4) + X[2],
> c (0, diam/4) + X[1],
> c ( -diam , -3*diam/4) + X[2], lwd= lw)
> }
>
> and to plot several iteams at a time
>
> female <- function (x, y, d= 1, p= 1, l= 1) {
> ## x, y vectors of x and y coordinates
> ## d: diameter
> ## p: proportion of symbol
> ## l: line width
>
> xy <- cbind (x, y)
> apply (xy, 1, FUN= one.female, diam= d, prop= p, lw= l)
> }
>
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list