[R] Font quality in base graphics

Jeffrey Horner jeff.horner at vanderbilt.edu
Tue Jul 15 17:58:07 CEST 2008


willemf wrote on 07/15/2008 08:42 AM:
> I am attempting to get publication quality graphs using R on Ubuntu. I
> encounter lots of problems in using cex to control font size: for instance
> cex=1.5 results in very blocky characters. I then tried to use res=1200
> while creating a PNG file, hoping that this would solve the problem, but it
> did not. When doing the above, a second problem appeared: the font size
> relative to the graphics decreased drastically. e.g. png("t1.png", res=1200,
> width=1200, height=1200). Is anyone prepared to give me a pointer of where
> to read about precise control over font type and font size in base graphics?
> I have two books on R graphics but this aspect is never treated in detail in
> any of them. Kind regards, willemf.

You may find some help with the Cairo package, which allows one to 
select desired truetype and opentype fonts using the fontconfig library. 
Be sure to thoroughly read the CairoFonts and CairoFontMatch help pages 
to learn how to carefully select your fonts. The benefit of using Cairo 
is that your png graphics have a better chance of looking exactly like 
your pdf graphics since Cairo embeds the fonts into the pdf by default.

Knowing which journal you're publishing in and their graphic 
requirements would be helpful to further solve your problem. Some 
researchers here at Vanderbilt have had success saving graphics as pdf's 
(with or without Cairo), then either using gimp or the imagemagic 
command convert to "upscale" the graphic to a desired dpi setting.

Best,

Jeff
-- 
http://biostat.mc.vanderbilt.edu/JeffreyHorner



More information about the R-help mailing list