[R] Garbled plot label

John Maindonald john.maindonald at anu.edu.au
Tue Apr 26 08:28:52 CEST 2005


Marc Schwartz (MSchwartz at MedAnalytics.com) wrote

> Here is another option. One issue is that given the way in which 
> plot.lm
> () is coded, some of the axis labels are hard coded when passed to the
> four underlying plot functions and as far as I can tell, there is no 
> way
> to use a 'par' and just blank out the x axis labels only. Thus, both x
> and y axis labels need to be blanked and then separately created using
> title().
>
> Thus, here is a plot.lm2() function. It's a bit kludgy, but it seems to
> work, though other eyes should look at it for any errors.
>
> What it effectively does is to do each of the four plots in plot.lm()
> individually without labels (ann = FALSE) and then adds them, generally
> based upon the way it is done in plot.lm(). The x axis labels are paste
> ()'d to the wrapped model expression to create a multi-line sub.title
> for each plot.
>
> The wrap.len argument is the 'width' argument for strwrap indicating 
> the
> target line wrapping length. Note that if you get to around 3 lines, 
> you
> will likely need to modify the margins in the plot for side 1 to 
> provide
> for more room.

I cannot see how to set this up so that it works in every situation.

The only clean and simple way that I can see to handle the problem
is to set a default that tests whether the formula is broken into 
multiple
text elements, and if it is then omit it.  Users can then use their own
imaginative skills, and such suggestions as have been made on
r-help, to construct whatever form of labeling best suits their case,
their imaginative skills and their coding skills.

The web page http://wwwmaths.anu.edu.au/~johnm/r/plot-lm/
has image files plot.lm.RData and plot6.lm.RData that are proposals
for a revised version of plot.lm(). The changes made so far do not
deal with the long formula issue, but if nothing better turns up my
proposal will be to proceed as I have just indicated.

John Maindonald             email: john.maindonald at anu.edu.au
phone : +61 2 (6125)3473    fax  : +61 2(6125)5549
Centre for Bioinformation Science, Room 1194,
John Dedman Mathematical Sciences Building (Building 27)
Australian National University, Canberra ACT 0200.




More information about the R-help mailing list