[R] Smoothed lines over barplots

Andrew Perrin andrew_perrin at unc.edu
Tue Feb 19 17:31:03 CET 2002


Greetings.

I'd like to generate a graph that displays two distributions as
side-by-side bar graphs, then plots a smoothed line of the distribution on
top. The idea is to be able to visually compare the distributions.

I've done the following, but the axes don't line up. Any suggestions?

barplot(table(hcd.df$datecat, hcd.df$auth.sum), beside=TRUE,
  legend.text=c('Pre-9/11','Post-9/11'),main='Authoritarian Sum',
  sub='Chi-Square: 33.88; p< .01',col=c('yellow','red'))
par(new=TRUE)
plot(table(hcd.df$auth.sum[hcd.df$datecat==1]), type='l',xlim=c(-8,7),
  ylim=c(0,59),col='yellow')
par(new=TRUE)
plot(table(hcd.df$auth.sum[hcd.df$datecat==2]), type='l',
  col='red',xlim=c(-8,7), ylim=c(0,59))


Thanks.

----------------------------------------------------------------------
Andrew J Perrin - andrew_perrin at unc.edu - http://www.unc.edu/~aperrin
 Assistant Professor of Sociology, U of North Carolina, Chapel Hill
      269 Hamilton Hall, CB#3210, Chapel Hill, NC 27599-3210 USA


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list