[R] Symbols for male/female

Lorenz Gygax gygax at ifi.unizh.ch
Thu Oct 31 08:10:25 CET 2002


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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list