Low-Level Plotting Function

DESCRIPTION:

Call mtext to add plotting labels to an axis, after first adjusting the labels so that the text does not overlap.

USAGE:

mtext.no.overlap(mtext.call, min.cex, min.trunc, min.gap=1) 

REQUIRED ARGUMENTS:

mtext.call
list giving the arguments to be passed to mtext (will be called with do.call("mtext", mtext.call) after adjustment). Must contain cex, text, side, adj, srt, font, and at elements.
min.cex
minimum value of the cex plotting parameter to use to avoid overlaps.
min.trunc
minimum fraction of label strings that must be retained when truncating to avoid overlaps.

OPTIONAL ARGUMENTS:

min.gap
minimum number of characters of gap required between adjacent labels.

VALUE:

the return value of mtext.

SIDE EFFECTS:

text is added to the plot by mtext.

DETAILS:

The function first checks to see if the label strings will overlap or not have the required gap between them. If they overlap, it first tries to avoid overlaps by reducing the cex parameter down to min.cex. If that still leaves overlapping labels, label strings will be truncated down to minimum fraction min.trunc. If they still overlap, alternate labels will be dropped. Then mtext will be called with the remaining labels and new cex.

SEE ALSO:

.

EXAMPLES:

plot(1:10) 
mtext.no.overlap(list(cex=1, text=rep("hellooooo",5), side=1, adj=0.5, srt=0,  
  at=seq(1,2,length=5), font=par("font"), line=3), min.cex=1, min.trunc=.6)