[R] catering for rescaling
Jim Lemon
jim at bitwrit.com.au
Mon Mar 10 21:27:07 CET 2014
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