[R] catering for rescaling

Geoffrey lordgeoffrey at optusnet.com.au
Tue Mar 11 10:36:34 CET 2014


Thanks Jim. I see you maintain the package. What r primitive do those 
functions use to do font metrics so that the margin can adjusted?
Geoff.

On 11/03/14 06:27, Jim Lemon wrote:
> On 03/10/2014 10:34 PM, Geoffrey wrote:
>> My barplot has nicely left justified horizontal labels, the names of
>> people. Written using text() . I use par("user")[1] - OFFSET to get the
>> placed nicely.
>>
>> Now of course if i manually rescale/zoom the plot the labels get redrawn
>> at the 'wrong' location, including off the left of the plot.
>>
>> I assume this is because the x-position is based off the size of a unit
>> in the plot, which changes when i rescale.
>>
>> Can i get some pointers on how to adjust for this?
>>
> Hi Geoffrey,
> This is a common problem when labels of arbitrary length are added to 
> the axis of a plot. The gantt.chart function in the plotrix package 
> works out the maximum length of the labels to be displayed and adjusts 
> the margins of the plot to suit. gantt.chart uses the axis function to 
> display the labels, and but you want left justification, so using 
> mtext makes it a bit easier. I tried changing the size of the example 
> in staircase.plot, which uses mtext, and it seemed to work okay.
>
> Jim
>
>




More information about the R-help mailing list