[R] multiline text() with different cex sizes

Uwe Ligges ligges at statistik.tu-dortmund.de
Mon Dec 3 16:29:12 CET 2012



On 03.12.2012 16:13, Michael Friendly wrote:
> 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.


Not in base R graphics, but in package "grid".

Best,
Uwe Ligges

> -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.
>>
>
>




More information about the R-help mailing list