[R] multiline text() with different cex sizes

Michael Friendly friendly at yorku.ca
Mon Dec 3 16:13:48 CET 2012


Well, no one answered this back in August, and now I have the same 
problem with another figure.

Again, is there some way to position several lines of text within
a plot written at different cex sizes so that the relative spacing of 
the lines remains fixed when the plot is resized or written to
a device?

That is, I'd like to have such caption text treated as a fixed block
which, under rescaling would expand contract uniformly.

-Michael


On 8/22/2012 2:58 PM, Michael Friendly wrote:
> 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. & Chair, Quantitative Methods
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