[R] negative superscripts in axis labels

glen e. p. ropella gepr at tempusdictum.com
Mon Aug 29 23:21:23 CEST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I apologize if this has been covered somewhere; but, I cannot find it.

The following results in a segmentation fault:
- -----------------------------------------------------------------
helvetica <- X11Font("-*-helvetica-*-*-*-*-*-*-*-*-*-*-*-*")
X11Fonts(helvetica=helvetica)
symbol <- X11Font("-*-symbol-%s-%s-*-*-%d-*-*-*-*-*-*-*")
X11Fonts(symbol=symbol)
X11(width=864, height=432,
~    fonts=c(X11Font(helvetica), X11Font(symbol)))

x <- seq(0,1,.0001)
y <- sin(x)
tics <- c(10^-5,10^-4,10^-3,10^-2,10^-1,10^-0)
lab0 <- expression(10^-0)
lab1 <- expression(10^-1)
lab2 <- expression(10^-2)
lab3 <- expression(10^-3)
lab4 <- expression(10^-4)
lab5 <- expression(10^-5)
plot(x,y,log="y",axes=FALSE)
axis(1)
axis(2,at=tics,labels=c(lab5,lab4,lab3,lab2,lab1,lab0))
- ------------------------------------------------------------------

However, if I remove the "-" symbols in the labels, e.g.
~    lab0 <- expression(10^0)
everything works just dandy.

Or, if I use par (family="sans") instead of setting the font family
using the X font string directly, the negative superscripts also work.
But, I have reasons for defining the font mappings manually.

Does anyone have any idea how I can get the negative superscripts to
work while using the explicitly defined font mappings?  Perhaps there's
a sprintf() function down in there somewhere that requires more C format
arguments? (causing the axis function to wrongly access memory when it
uses the font mapping)

In the meantime, even when I simply increase the size of the axis labels
using cex.axis (e.g. par(cex.axis=1.02)), the "-" is just dropped from
those labels.  So, if I use: lab1 <- expression(10^-1), I get 10^1 in
the output.  I've tried all manner of inserting phantom() calls and
those don't work.  It's like the negative is ignored when the font size
increases.

Thanks very much for any pointers.
- --glen
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDE3xTZeB+vOTnLkoRAosIAJoCzCaOqZjkC+TjsdO7fttZojFJIQCfWItm
HafgrPzreKVoOBSB61+ykBE=
=JtVh
-----END PGP SIGNATURE-----




More information about the R-help mailing list