title: R - boxplot with multiple factor labels
body: <p>I'm working on trying to make a boxplot in R-cran that is categorized by two different factors on the x-axis. My problem lies in creating labels for one factor with +20 levels that spans the entire graph appropriately while using a legend to label the second factor which has only 2 to 3 levels.</p>
  
  <p>Here is a test script that roughly mimics my actual dataset:</p>
  
  <pre><code>d&lt;-data.frame(x=rnorm(1500),f1=rep(seq(1:20),75),f2=rep(letters[1:3],500))
  # first factor has 20+ levels
  d$f1&lt;-factor(d$f1)
  # second factor a,b,c
  d$f2&lt;-factor(d$f2)
  
  boxplot(x~f2*f1,data=d,col=c("red","blue","green"),frame.plot=TRUE,axes=FALSE)
  
  # y axis is numeric and works fine
  yts=pretty(d$x,n=5)
  axis(2,yts)
  
  # I know this doesn't work; what I'd like is to spread the factors out 
  # so the each group of three(a,b,c) is labeled correctly
  axis(1,at=seq(1:20))
  
  # Use the legend to handle the f2 factor labels
  legend(1, max(d$x), c("a", "b","c"),fill = c("red", "blue","green"))
  </code></pre>
  
  <p>Thanks for any help</p>