[R] multiline text() with different cex sizes

Michael Friendly friendly at yorku.ca
Wed Aug 22 20:58:40 CEST 2012


This question has probably been asked & answered before, but I can't 
find it: How to print a
multiline figure caption in a plot, where different lines have different 
fonts and font sizes,
and so that the lines of text are spaced in a reasonable way.

Here's a simple  example, where I have to keep tweaking the y coordinate 
and the
cex combos, while I also manually adjust the aspect ratio of the plot.  
But, once I get it looking
OK on the screen, when I print to a PDF device, the lines of text move 
around.

op <- par(mar=c(4,4,1,1)+.01)   # tight bounding box
plot(1:79, type="n",
     xlab="Year", ylab="", cex.lab=1.5,
     xlim=c(1500, 2000))

text(1610, 75, "Specimen of a\nChart of Biography", cex=2.5, font=4)
text(1610, 69, "of Milestones Authors", cex=1.5, font=4)
par(op)

In my real application, I would also add other lines of text in a 
smaller font size.

-- 
Michael Friendly     Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University      Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele Street    Web:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA



More information about the R-help mailing list