title: 2-layer barplot in R
body: <p>I am trying to build a (somewhat) complex barplot in R. The idea is to overlay two charts, whereby the bars in one are wider than in the other one, such that both bars are always visible.</p>
  
  <p>Here's what I have right now:</p>
  
  <pre><code># GENERATE THE DATA  
  Age = c(50, 55, 60, 65, 70)                                     # Age groups  
  Male = c(15.4, 24.3, 37.0, 54.6, 71.1)                          # Death rates for males  
  Female = c(8.4, 13.6, 19.3, 35.1, 50.0)                         # Death rates for females  
  Deathrate = matrix(c(Male,Female), nrow=length(Age), ncol=2, dimnames=list(Age, c("Male","Female")))         
  
  # GENERATE THE DATA  
  barplot(Deathrate[,1], col="red")
  par(new=TRUE)
  barplot(Deathrate[,2], space=1, col="blue")
  </code></pre>
  
  <p>Now, as you can see, the two plots are shown, but while both middle bars are nicely overlapping and centered, all other bars are not centered. For example, the rightmost blue bar is shown on the edge of the rightmost red bar.</p>
  
  <p>Does anyone have a simple solution to center <em>all</em> bars?</p>
  
  <p>Thanks, Philipp</p>
  
  <p>PS I know that the chart isn't pretty (overlapping legends etc.)....</p>