Skip to content

How to use fixed-width fonts such as courier in R

4 messages · Paul Murrell, xiang li

#
Hi,
  I am trying to use Arial bold for labelling (font.lab =2), and use
the fixed-width Courier bold for axis. I will export the plot to .ps
format. I have been trying to use font.axis = 11, but that doesn't work
when I exported the plot to a .ps file.

  I have been trying hard to read the help page of "postscript" these few
days, but didn't get the courier font yet.  Can you please help me
figure out how I should use "postscript"? Thanks!

Best

Sean
#
the problem is how to use both courier bold font for axis and arial
bold font for labelling.  If I use familiy = "courier" in postscript,
everything will become courier fonts ......

I noticed that in postscirpt help page, we can customize a family such as
"family = c("CM_regular_10.afm","CM_boldx_10.afm", "cmti10.afm",
"cmbxti10.afm", "CM_symbol_10.afm";

However, I tried many times, and just don't know the symbol used in R for
courier bold or arial bold, etc.
#
Hi

Does this do what you want?

postscript("example.ps", fonts=c("sans", "mono"))
plot(1:10, axes=FALSE, ann=FALSE)
par(family="sans") # By default Helvetica which is like Arial
title(xlab="sans serif axis label")
title(ylab="bold sans serif axis label", font.lab=2)
par(family="mono") # By default Courier
axis(1,
      at=seq(2, 8, 2),
      label=c("mono", "space", "tick", "labels"))
axis(2,
      at=seq(2, 10, 2),
      label=c("bold", "mono", "space", "tick", "labels"),
      font.axis=2)
box()
dev.off()

You might also want to take a look at the article "Fonts, lines, and 
transparency ..." in R News 4/2 
http://cran.stat.auckland.ac.nz/doc/Rnews/Rnews_2004-2.pdf

Paul
Xiang Li wrote:

  
    
#
Great. Thanks a lot. That is exactly what I need.

Xiang
On Wed, 25 May 2005, Paul Murrell wrote: