[R] How to get special (Hershey) font symbols into plot axis labels?

Uwe Ligges ligges at statistik.uni-dortmund.de
Tue Mar 12 09:11:09 CET 2002


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



More information about the R-help mailing list