Hello all,

I am trying to use computer modern fonts in my r grahics. I tried to do, as described here: http://www.stat.auckland.ac.nz/~paul/R/CM/CMR.html but unfortunately, it does not work.

First of all I downloaded the cm-lgc package and the AFM and PFB-files from the page and put them in my R working directory, so far, so good.

Then I tried to run the following code:

sn <- seq(1,7,length=100)
sm <- seq(0,4,length=100)
f <- function(x,y) {5.64080973 + 0.12271038*x - 0.27725481 * y + 0.29281216*x*y}
z <- outer(sn,sm,f)

nrz <- nrow(z)
ncz <- ncol(z)
jet.colors <- colorRampPalette( c("yellow", "red") ) nbcol <- 100
color <- jet.colors(nbcol)
zfacet <- z[-1, -1] + z[-1, -ncz] + z[-nrz, -1] + z[-nrz, -ncz]
facetcol <- cut(zfacet, nbcol)

CM <- Type1Font("CM",
                     c("cm-lgc/fonts/afm/public/cm-lgc/fcmr8a.afm",
                       "cm-lgc/fonts/afm/public/cm-lgc/fcmb8a.afm",
                       "cm-lgc/fonts/afm/public/cm-lgc/fcmri8a.afm",
                       "cm-lgc/fonts/afm/public/cm-lgc/fcmbi8a.afm",
"cmsyase.afm")) postscriptFonts(CM=CM)
pdf("snxsm.pdf")
par(family="CM")
persp(sn,sm,z,xlab="SN", 
ylab="SM",zlab="VI",theta=-20,phi=20,r=5,shade=0.01,col=color[facetcol])
dev.off()

It works fine, until the persp() function, there I get:

persp(sn,sm,z,xlab="SN", 
ylab="SM",zlab="VI",theta=-20,phi=20,r=5,shade=0.01,col=color[facetcol])
Error in persp.default(sn, sm, z, xlab = "SN", ylab = "SM", zlab = "VI", : Invalid font type
In addition: Warning messages:
1: In persp.default(sn, sm, z, xlab = "SN", ylab = "SM", zlab = "VI",  :
  font family not found in PostScript font database
2: In persp.default(sn, sm, z, xlab = "SN", ylab = "SM", zlab = "VI",  :
  font family not found in PostScript font database
3: In persp.default(sn, sm, z, xlab = "SN", ylab = "SM", zlab = "VI",  :
  font family not found in PostScript font database
4: In persp.default(sn, sm, z, xlab = "SN", ylab = "SM", zlab = "VI",  :
  font family not found in PostScript font database
5: In persp.default(sn, sm, z, xlab = "SN", ylab = "SM", zlab = "VI",  :
  font family not found in PostScript font database

Any help is appreciated! Also a hint/link how to install the CM fonts under R for general use, so that I don't have to have it in my wd all the time.

Thank you very much!

Greetings,
Friedericksen

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to