[R] forcing all tick labels to plot

William Briggs wib2004 at med.cornell.edu
Wed Jan 19 21:43:16 CET 2005


I'm trying to find a way to force all the x-axis tick labels to plot, 
regardless whether or not they overlap or look pretty.

V is a factor with, say, 4 levels.  A call to plot(V) gives a 
histogram-like plot, one bar for each level in V.  The problem is that 
all the label names may not be plotted because some of the names are 
lengthy and would tend to overlap if plotted.

I don't care if they do, I want to see all the labels, overplotted or not.

I tried:

     plot(V,axes=F)
     d<-levels(V)
     axis(1,at=1:4,label=d)
     axis(2)

But this does nothing more than the default, that is, only some of the 
labels print.  The other problem is the "at=1:4", which is my guessing 
where the tickmarks go.  The function "axTicks(1)" may help, but it 
frequently has more tick marks then levels in "V", so again I have to 
guess which goes where.

I see this:

     c<-par()
     c$xaxp = 0.5 3.5 4

or something similar.  Is there another par() in which the tick marks 
that are calculated are given explicitly?

I have tried:

     par(cex=.7)

and that works for some V, but not for all, and it isn't a very general 
solution.

Is there some flag that I can set to force all the tick labels to plot?

Matt Briggs




More information about the R-help mailing list