[R] barplot_add=TRUE

Jim Lemon drjimlemon at gmail.com
Tue Jan 9 09:55:43 CET 2018

Hi Sibylle,
I might have the wrong idea, but does this:


do what you want? It is also possible to display this as a nested bar
plot showing males and females within total catch.


On Tue, Jan 9, 2018 at 7:19 PM, Sibylle Stöckli <sibylle.stoeckli at gmx.ch> wrote:
> Dear R users
> aim
> Barplot of insect trap catches (y variable trapcatch) at one specific station (variable FiBL_Hecke) from week 1-52 ( x variable week).
> It works well using the function tapply (sum trapcatch per week, males and females not separated), however, I intend to separate the y variable trapcatch in males and females (variable m_w: m and w)
> problem
> I used the function "add" to merge two bar plots (males and females). Unfortunately the second barplot masks the first barplot.
> question
> Is there a function to "mathematically" add the values from both barplots with the aim the barplot presenting the total trap (males and females) catches per week?
> Hecke<-trap[trap$station=="FiBL_Hecke",] # station = Hecke
> m<-Hecke[Hecke$m_w=="m",] # male trap catches
> w<-Hecke[Hecke$m_w=="w",] # female trap catches
> barplot(m$trapcatch, ylab="Y", space=0.5, col=c("grey0"), ylim=c(0,450), las=2, cex.lab=0.9, cex.axis=0.9, cex.names=0.9)
> barplot(w$trapcatch,space=0.5, add=TRUE, beside=FALSE, col=c("grey50"), xaxt="n", yaxt="n")
> Thanks a lot
> Sibylle
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list