[R] A problem with plotting a long expression in ylab ?

Ben Bolker bbolker at gmail.com
Tue Sep 28 23:15:36 CEST 2010


Barry Rowlingson <b.rowlingson <at> lancaster.ac.uk> writes:

> > My point is that in regular text, ylab plots it where it then goes outside
> > the borders.
> > With the use of expressions - the text just doesn't show up.
> > Originally I thought it was because of my miss-use of expressions, until I
> > figured it was the level of cex.lab I was using.
> > The problem is that when you can't see the text, you don't have a sense of
> > how much to decrease the cex.lab so the text will fit.
> > I hope I was now clearer.
> 
> Gotcha. Seems to only affect ylab though. Do this:
> 
>  > t =  expression(paste("test
> loooooooooooooooooooooooooooooooooooooooooooooo(% of 360" *degree,
> ")"))
>  > plot(1,xlab=t,ylab=t,main=t)
> 
> then if I shrink my graphics window I can make the ylab disappear but
> not the xlab or title.
> 
>  Seems to affect any rotated expressions:
> 
> > plot(1)
> > text(1,1,t,srt=90)
> > text(1,1,t,srt=0)
> > text(1,1,t,srt=45)
> 
>  Now shrink window and watch the rotated expressions vanish! They
> disappear when they start (or finish) out of the entire graphics
> device, not the plot region...
> 
>  I cant find anything relating to clipping in the help, and I am on
> Linux, so see if there's any news about it, try it with R-patched or
> R-devel and then report a bug after having read all the other stuff
> about R bug reporting!
> 
> Barry


   I don't claim to understand it, but there is something quite
fundamental about the properties of the X11() graphics device in R
that makes labels that would otherwise overlap, disappear -- if
you do 'extreme resizing' with the graphics above, you can see that
otherwise-overlapping x- and y-axis tick labels disappear as the
graph gets scrunched.  This is (apparently) true of X11 graphics
on MacOS as well -- Quartz window has a different behavior.
Trying with pdf() as well -- for height=2, width=2, only 1 y-axis
and 2 x-axis tick labels survive, *but* the x and y labels and the
title are all still present (but clipped, of course).
   [Hmmm. Take my reports above with a grain of salt, I wasn't
always using expression()s.]

  So I would guess that if you reported this as a bug you would
be told that it was a poorly documented property of R's X11
graphics model, rather than a bug ...

  I have no idea where to start looking for more information
about what defines this behavior -- if I were desperate to know
I would probably try asking Paul Murrell ...

  I would be very interested to see this discussed on r-devel,
if anyone bit ...

   Ben Bolker



More information about the R-help mailing list