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

Joe Mazzarella mazz at ipac.caltech.edu
Tue Mar 12 20:44:35 CET 2002


Thanks for the suggestions, Uwe and Paul.
Here's some feedback that includes a problem with the rendered
vector fonts in Postscript:

> You cannot use the font in expressions.


That's a limitation that should be solved one day.

Otherwise users can't get special symbols in subscripts or superscripts,
which is often where they are needed.

 
> 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()").

Right. But it's good to know this is in the plans, anyway.


> 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"))


OK, but since we can't plot \\SO in a subscript using

text(x,y,expression(paste("Log ",rho," (",Mpc^-3," ",M[ir]^-1,")"))),
I had to kludge further to fake the subscripts:

###############################################
par(pin=c(6.0,6.0)) #6" X 6" figure
par(xpd=TRUE)
plot(BinLir,logpho,
   xlab="",
   ylab=expression(paste("Log ",rho," (",Mpc^-3," ",M[ir]^-1,")")),
   xlim=c(7.4,12.9),ylim=c(-9.0,-0.2),pch=1,
   vfont=c("serif","plain")
)
text(10.00,-10.30,"log (L",vfont=c("serif","plain")) #"log (L"
text(10.38,-10.35,"ir",vfont=c("serif","plain")) #fake "ir" subscript
text(10.54,-10.30,"/L",vfont=c("serif","plain")) #"/L"
text(10.72,-10.35,"\\SO",vfont=c("serif","plain")) #fake "Solar" subscript
text(10.82,-10.30,")",vfont=c("serif","plain")) #")"
################################################

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?

I need to plot other special symbols in sub/superscripts as well.
I tried annotating R plots using bitmaps in xfig, but that does not
turn out very well either. I'll probably have to use a different plotting
package until special symbol subscript/superscript support improves in R.

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



More information about the R-help mailing list