Hi there,
last week I posted a question regarding the use of special characters in plots
titles, axis labels, etc. I got two answers, one from Alan Zaslavsky and the
other from Pierre Joyet. Thanks to both of them. Alan's reply follows and
Pierre's also, translated since it was written in French (neat). Since I am on
PC I ended up using Pierre's solution.
Thanks to both,
Gérald Jean
Analyste-conseil (statistiques), Actuariat
télephone : (418) 835-8839
télecopieur : (418) 835-5865
courrier électronique: gerald.jean@spgdag.ca
"In God we trust all others must bring data"
---------------
Pierre's solution:
Bonjour !
This function will display all available characters.
character.table <- function()
{
v <- 40:377
v <- v[v %% 100 < 80 & v %% 10 < 8]
par(mar = c(5, 5, 4, 2) + 0.1)
plot(0:7, seq(4, 31, length = 8), type = "n", axes = F, xlab = "",
ylab = "")
k <- 1
for(i in 4:31)
for(j in 0:7) {
text(j, 35 - i, eval(parse(text = paste("\"\\", v[k], "\"",
sep = ""))))
k <- k + 1
}
text(0:7, rep(33, 7), as.character(0:7), font = 3)
text(rep(-1, 28), 31:4, as.character(c(4:7, 10:17, 20:27, 30:37)),
font = 3)
}
Now type:
> graphsheet(orientation = "portrait")
> character.table()
and print the resulting graphsheet. The printed version doesn't allways
corresponds to the screen display. The character on line "xy" and column "z"
of the table has code "xyz".
These codes can be used as any other characters. e.g.
> title("\347\340 et \340")
As the command line window of Splus can't print special characters
> cat("\347\340 et \340")
will not print the special characters, at least under 4.5 and under 2000.
Another way of using special characters in graphs without having to look
at the table is to use
> title(edit(""))
with an editor having the capability of accepting special characters (I use
Emacs
for NT and haven't figure out yet how to make it accept special chars. G.J)
Better yet to create a permanent editable object use:
> titre <- ""
> title(titre <- edit(titre))
J'espère que ces quelques indications vous seront utiles.
Salutations
Pierre Joyet
_______________________________________________________________________________________________
Now Alan's reply:
This is a definite FAQ - shows up about once every year. Here are several
solutions:
(1) for a single Greek character: use the "symbol" font (Font 13 on Unix
systems, I don't know about the PCs).
(2) if it suits your needs and you are on a PC, use the graph editing
features.
(3) if you need to mix things up in one label, use my "postscriptfonts"
archive from Statlib. THese functions allow you to create simple to
moderately complex labels using a string with escape sequences for change
of font, super and subscripts, change of size, etc. Takes some fiddling
to make it beautiful but it works entirely within S-plus.
(4) use the "psfrag" utilities (there are a few variations around) that
work with LaTeX or TeX, so you can create the label in those languages and
have them appear within a PostScript plot. THe way to go for truly
high-quality typesettnig, but requires some additional steps.
Thanks again to both
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|