Joe Mazzarella
2002-Mar-12 01:08 UTC
[R] How to get special (Hershey) font symbols into plot axis labels?
Dear R experts- I'm running R 1.2.3 (2001-04-26) on Linux. I need to get special symbols, such as a circle with a dot in it as used to indicate Solar units in astronomy, into my plot axis labels. How can I do this? Using the R documentation on the Hershey font sets, one can plot a Solar symbol within the world coordinates of a plot like this: >plot(1:10,1:10) >text(4,8,"\\SO",vfont=c("serif","plain")) That works fine; however, trying to get the symbol into a plot label with a call like this: >plot(BinLir,logpho, xlab=expression(paste("Log (",L[ir]," / ","\\SO",")")), ylab=expression(paste("Log ",rho," (",Mpc^-3," ",M[ir]^-1,")")), xlim=c(8.0,12.9),ylim=c(-9.0,-0.2),pch=1, vfont=c("serif","plain") ) gives Warning messages: 1: parameter "vfont" couldn't be set in high-level plot() function 2: parameter "vfont" couldn't be set in high-level plot() function 3: parameter "vfont" couldn't be set in high-level plot() function 4: parameter "vfont" couldn't be set in high-level plot() function I also tried this: >mtext("\SO",vfont=c("serif","plain")) and got Warning message: Hershey fonts not yet implemented for mtext() in: mtext(text, side, line, outer, at, adj, cex, col, font, vfont, Finally I tried this: >title(xlab=expression(paste("Log (",L[ir]," / ","\SO",")")),vfont=c("serif","plain")) and got Warning message: parameter "vfont" couldn't be set in high-level plot() function Another possible solution, but less general, would be to combine (over-strike) a circle symbol with a small dot symbol. Can this be done in title(), mtext(), or plot(x,y,xlab=[WHAT?])? I actually need to get the Hershey "\\SO" symbol, or its equivalant, into a plot label *subscript*. Is there any way to do this? If not, when is this capability expected in an R update? Any help will be greatly appreciated. Thanks. -Joe -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Uwe Ligges
2002-Mar-12 08:11 UTC
[R] How to get special (Hershey) font symbols into plot axis labels?
Joe Mazzarella wrote:> > Dear R experts- > > I'm running R 1.2.3 (2001-04-26) on Linux.Please upgrade to R-1.4.1.> I need to get special symbols, such as a circle with a dot in it > as used to indicate Solar units in astronomy, into my plot axis labels. > How can I do this? > > Using the R documentation on the Hershey font sets, one can plot > a Solar symbol within the world coordinates of a plot like this: > > >plot(1:10,1:10) > >text(4,8,"\\SO",vfont=c("serif","plain")) > > That works fine; however, trying to get the symbol into a plot label > with a call like this: > >plot(BinLir,logpho, > xlab=expression(paste("Log (",L[ir]," / ","\\SO",")")), > ylab=expression(paste("Log ",rho," (",Mpc^-3," ",M[ir]^-1,")")), > xlim=c(8.0,12.9),ylim=c(-9.0,-0.2),pch=1, > vfont=c("serif","plain") > ) > gives Warning messages: > 1: parameter "vfont" couldn't be set in high-level plot() function > 2: parameter "vfont" couldn't be set in high-level plot() function > 3: parameter "vfont" couldn't be set in high-level plot() function > 4: parameter "vfont" couldn't be set in high-level plot() function > > I also tried this: > >mtext("\SO",vfont=c("serif","plain")) > and got Warning message: > Hershey fonts not yet implemented for mtext() in: > mtext(text, side, line, outer, at, adj, cex, col, font, vfont, > > Finally I tried this: > >title(xlab=expression(paste("Log (",L[ir]," / ","\SO",")")),vfont=c("serif","plain")) > and got Warning message: > parameter "vfont" couldn't be set in high-level plot() function > > Another possible solution, but less general, would be to combine (over-strike) > a circle symbol with a small dot symbol. Can this be done in title(), > mtext(), or plot(x,y,xlab=[WHAT?])? > > I actually need to get the Hershey "\\SO" symbol, or its equivalant, into a > plot label *subscript*. Is there any way to do this? > If not, when is this capability expected in an R update?No, but you should upgrade anyway.> Any help will be greatly appreciated.You cannot use the font in expressions. Looks like there is a bug (at least in the documentation). ?Hershey: "If the vfont argument to one of the text-drawing functions (text, mtext, title, axis, and contour) is a character vector of length 2, hershey vector fonts are used to render the text." But it doesn't work for: axis() (without a warning message), title() ("Warning message: parameter "vfont" couldn't be set in high-level plot() function") and, mtext() ("Warning message: Hershey fonts not yet implemented for mtext()"). What you can do is using text() as in: plot(1:10, xlab="") par(xpd=TRUE) text(5.5, -0.5, "\\SO", vfont=c("serif","plain")) Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Joe Mazzarella
2002-Mar-14 02:39 UTC
[R] How to get special (Hershey) font symbols into plot axis labels?
Dear Paul,>>The bad news: >>Although this looked fine in the default X-window plot device, >>using the Postscript device via >> postscript(file="LumFunc.ps",horizontal=FALSE, onefile=FALSE, >> > paper="letter") > >> #above plot commands... >> dev.off() >>produces an x axis label with a "fuzzy" or "grayed out" appearance >>(the vector font lines are not solid black) which is unacceptable >>for publication. If I use vfont only for the faked Solar subscript, >>then the rest of the text is solid black but the Solar >>subscripts is fuzzy. >> >>Any ideas how to "un fuzz" vector font text in the Postscript device? >> > > > Hmmm. I don't get this on my setup and I'm not sure what would cause it. > Just to check ... is this "fuzzy" appearance on the printed output or only > viewing the postscript via ghostview or something? If the latter, then > maybe you are just seeing antialiasing -- its a long shot, but worth > checking :)You are correct. The "fuzziness" of the vector font is only when viewed on the monitor using 'gv'. When the Postscript file is printed, the symbol made with the vector font prints solid black just like characters using the normal default font. However, since so many science publications are now presented digitally in online journals and preprint services, many readers increasingly view PS or PDF files on their computer (e.g., while working on their own research papers) and don't always bother to print hardcopy. Paper is fast becoming a secondary medium of choice. Interestingly, I find that if I convert the PS file to PDF (on Linux) via ps2pdf LumFunc.ps LumFunc.pdf and view with 'xpdf LumFunc.pdf', the vector font symbols still appear fainter/fuzzier than the rest, but less so than PS viewed in 'gv'. Many thanks to you and others who responded. R is a great package for data analysis and sci/tech graphics, and support through r-help is fantastic. Your dedication to this work is much appreciated. Best regards. -Joe -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._