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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Thursday, October 31, 2002 7:10 AM, Lorenz Gygax [SMTP:gygax at ifi.unizh.ch] wrote:> 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.The male and female symbols are available in the Hershey fonts so can be added via text, for example: text(x,y,"\\MA",vfont=c("sans serif","bold")) # male symbol text(x,y,"\\VE",vfont=c("sans serif","bold")) # female symbol These are not the best looking fonts ion my opinion, but this may be the quickest solution for the moment. David Dr David A. J. Middleton, Stock Assessment Scientist Fisheries Department, Falkland Islands Government Stanley, Falkland Islands Tel: +500 27260 Fax +500 27265 Email: dmiddleton at fisheries.gov.fk Web: http://www.falklandislands.com/business/fisheries.htm -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
(diverted to R-devel; I'll send a shorter reply to R-help)>>>>> "Lorenz" == Lorenz Gygax <gygax@ifi.unizh.ch> >>>>> on 31 Oct 2002 08:10:25 +0100 writes:Lorenz> Dear all, Lorenz> I would like to use the biological symbols for male Lorenz> and female as plotting symbols in a scatterplot Lorenz> (ideally filled and non-filled). R does not seem to Lorenz> have these symbols using pch= in plot() nor are they Lorenz> implemented via expression() or at least I did not Lorenz> find them. I found that the symbols are Lorenz> e.g. available in the wasysym and the marvosym Lorenz> package in LaTeX. Lorenz> I have coded two very rough functions that are able Lorenz> to approximate those symbols, but not surprisingly, Lorenz> they are not very efficient regarding the file size Lorenz> they produce (I have included the code for the Lorenz> female symbol at the end of the mail). Lorenz> Is there a more or less straightforward way to Lorenz> implement these symbols so that they can be accessed Lorenz> either by pch= or expression()? Can you give me some Lorenz> pointers on how I would need to go about this? It's rather "less" than "more" straightforward ;-) : In src/main/graphics.c, you look for the function GSymbol(). There, you see how each (pch = <integer>) symbol is done. In principle, you just would add new case statements; pch = 26 and pch =27 would be the next free ones ... Probably you need to poke around a bit in the C source of R in order to learn how to do this. In this case, the source is the documentation. There have been wishes and dreams about using something like pch = <<pointer to (jpg|pdf|eps|png|...) file>> which of course would be much more general and useful, but needs much more work of course! Maybe rather something that would only be done in the new graphics system which the grid package provides ? Greetings up the hill (in Zürich)! Martin Maechler <maechler@stat.math.ethz.ch> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <>< Lorenz> Thanks and regards, Lorenz Lorenz> -- Lorenz> Lorenz Gygax, Dr. sc. nat. Lorenz> Artificial Intelligence Lab, Department of Information Technology Lorenz> University of Zurich-Irchel, +41-1-635 67 17, gygax@ifi.unizh.ch Lorenz> one.female <- function (X, diam= 1, prop= 1, lw= 1) { Lorenz> ## X a vector giving the position of the symbol c (x, y) Lorenz> ## diam: diameter in the entities on the Y axis Lorenz> ## prop: proportion of x to y axis (so that symbols will be round Lorenz> ## lw: adjustment of line width for large symbols Lorenz> x.ring <- cos (seq (0, 2*pi, len= 500)) * prop * diam/2 Lorenz> y.ring <- sin (seq (0, 2*pi, len= 500)) * diam/2 Lorenz> lines (x.ring + X[1], y.ring + X[2], lwd= lw) Lorenz> segments (c (0, -diam/4) + X[1], Lorenz> c (-diam/2, -3*diam/4) + X[2], Lorenz> c (0, diam/4) + X[1], Lorenz> c ( -diam , -3*diam/4) + X[2], lwd= lw) Lorenz> } Lorenz> and to plot several iteams at a time Lorenz> female <- function (x, y, d= 1, p= 1, l= 1) { Lorenz> ## x, y vectors of x and y coordinates Lorenz> ## d: diameter Lorenz> ## p: proportion of symbol Lorenz> ## l: line width Lorenz> xy <- cbind (x, y) Lorenz> apply (xy, 1, FUN= one.female, diam= d, prop= p, lw= l) Lorenz> } -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> "Lorenz" == Lorenz Gygax <gygax at ifi.unizh.ch> >>>>> on 31 Oct 2002 08:10:25 +0100 writes:Lorenz> Dear all, Lorenz> I would like to use the biological symbols for male Lorenz> and female as plotting symbols in a scatterplot Lorenz> (ideally filled and non-filled). R does not seem to Lorenz> have these symbols using pch= in plot() nor are they Lorenz> implemented via expression() or at least I did not Lorenz> find them. I found that the symbols are Lorenz> e.g. available in the wasysym and the marvosym Lorenz> package in LaTeX. Lorenz> I have coded two very rough functions that are able Lorenz> to approximate those symbols, but not surprisingly, Lorenz> they are not very efficient regarding the file size Lorenz> they produce (I have included the code for the Lorenz> female symbol at the end of the mail). Lorenz> Is there a more or less straightforward way to Lorenz> implement these symbols so that they can be accessed Lorenz> either by pch= or expression()? Can you give me some Lorenz> pointers on how I would need to go about this? I've just replied to this in some length on R-devel rather than R-help since my answer really is about future development of R, here. The short answer: It is not straightforward but doable in principle by hacking in the R source, learning some of the internal graphics system (done in C). Please use R-devel at .. for further discussion. Martin Maechler <maechler at stat.math.ethz.ch> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <>< -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Curtis Clark has made TrueType fonts that include male/female symbols; the license is quite liberal (and included with the fonts). Could it help? I can send you the packet. Zdenek Skala skala at incoma.cz -----Original Message----- From: Lorenz Gygax [mailto:gygax at ifi.unizh.ch] Sent: Thursday, October 31, 2002 8:10 AM To: r-help at stat.math.ethz.ch Subject: [R] Symbols for male/female 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On 31 Oct 2002 08:10:25 +0100 Lorenz Gygax <gygax at ifi.unizh.ch> wrote:> > 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. > >. . . Bill Cleveland's "The Elements of Graphing Data" gives a good explanation of why this type of encoding is ineffective, and he gives some solutions that can already be executed in R. Frank Harrell -- Frank E Harrell Jr Prof. of Biostatistics & Statistics Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences U. Virginia School of Medicine http://hesweb1.med.virginia.edu/biostat -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
If you're using LaTeX anyway, one possibility is to use the psfrag package to post-process the postscript ... testmf.R ---------------- x <- runif(10) y <- runif(10) mf <- sample(0:1,10,TRUE) postscript("testmf.eps",width=4,height=4, horizontal = FALSE, onefile = FALSE, paper = "special") plot(x,y,type="n") text(x,y,ifelse(mf==0,"m","f")) dev.off() testmf.tex ----------------- \documentclass{article} \usepackage{graphicx} \usepackage{psfrag} \usepackage{wasysym} \psfrag{m}{\mars} \psfrag{f}{\venus} \begin{document} \includegraphics{testmf} \end{document} On 31 Oct 2002, Lorenz Gygax wrote:> > 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 >-- 318 Carr Hall bolker at zoo.ufl.edu Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker Box 118525 (ph) 352-392-5697 Gainesville, FL 32611-8525 (fax) 352-392-3704 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._