Nothing
#
# plot_for_each_gear_catch_by_guild.R
#
#' Plots of annual integrated catch compositions by each gears for the final year of a model run
#'
#' Multi-panel bar-plots of the annual integrated catch compositions by each gears for the final year of a model run generated by the e2e_run() function
#'
#' The function plots a multi-panel page of bar-plots of guild compositions of the annual integrated catches
#' by each of the the gears in the fishing fleet model (up to 12, user defined).
#'
#' Each panel represesents a single gear. In each panel, the x-axis represents the 10 guilds in the ecology model which are potentially catchable, and the y-axis is the annual integrated catch.
#' For each guild there are two bars corresponding to the inshore and offshore zones. Each bar is subdivided into landed and discarded components of the catch.
#' Green and blue sections are offshore and inshore landings respectively; black and grey sections are offshore and inshore discards respectively.
#'
#' Units for the catch are mMN/m2/year
#'
#' @param model R-list object defining the model configuration compiled by the e2e_read() function
#' @param results R-list object containing model results generated by the e2e_run() function
#'
#' @return Graphical display in a new graphics window
#'
#' @importFrom graphics barplot title grconvertX grconvertY
#'
#' @noRd
#
# ------------------------------------------------------------------------------
plot_for_each_gear_catch_by_guild <- function(model, results) {
start_par = par()$mfrow
on.exit(par(mfrow = start_par))
final.year.outputs <- elt(results, "final.year.outputs")
offshore_catchmat <- elt(final.year.outputs, "offshore_catchmat")
offshore_discmat <- elt(final.year.outputs, "offshore_discmat")
offshore_landmat <- elt(final.year.outputs, "offshore_landmat")
inshore_catchmat <- elt(final.year.outputs, "inshore_catchmat")
inshore_discmat <- elt(final.year.outputs, "inshore_discmat")
inshore_landmat <- elt(final.year.outputs, "inshore_landmat")
ngears <- 12
#expects the matrices catchmat and catchmat_t, landmat and landmat_t, doscmat and discmat_t
#----------------------------------------------------------------
#In each plot panel:
# black and grey are offshore and inshore discards respectively
# green and blue are offshore and inshore landings respectively
#----------------------------------------------------------------
par(mfrow=c(4,3))
par(mar=c(4,5,1.2,0.5))
for(dsa in 1:ngears) {
mt<-(colnames(offshore_catchmat))[dsa]
offshore_data2plot<-rbind(offshore_discmat[,dsa],offshore_landmat[,dsa])
inshore_data2plot<-rbind(inshore_discmat[,dsa],inshore_landmat[,dsa])
colnames(offshore_data2plot)<-c("PF","DFq","DFnq","MF","Bsd","Bcs","CZ","BD","PIN","CT","MP")
if(sum(offshore_data2plot+inshore_data2plot)>0) {
yaxmax<-(1.2*max(c(offshore_catchmat[,dsa],inshore_catchmat[,dsa])))
}
if(sum(offshore_data2plot+inshore_data2plot)==0) {
yaxmax<-1
}
barplot(offshore_data2plot,col=c("black","green"),ylim=c(0,yaxmax),xlim=c(0,12),width=rep(0.5,11), space=c(0.5,rep(1.2,10)),yaxt="n",ann=FALSE,cex.axis=0.5)
axis(side=2,las=1,cex.axis=0.9)
if(dsa==1) mtext("Catch",cex=0.7,side=2,line=3.5)
if(dsa==4) mtext("Catch",cex=0.7,side=2,line=3.5)
if(dsa==7) mtext("Catch",cex=0.7,side=2,line=3.5)
if(dsa==10) mtext("Catch",cex=0.7,side=2,line=3.5)
title(main=mt,cex.main=1.0,line=+0.02)
barplot(inshore_data2plot,col=c("grey","blue"),add=T,width=rep(0.5,11), space=c(1.5,rep(1.2,10)),yaxt="n",xaxt="n",ann=FALSE)
}
legend(grconvertX(0.15, "ndc", "user"), grconvertY(0.05, "ndc", "user"),
c( "offshore landings","offshore discards","inshore landings","inshore discards"),
fill = c("green","black","blue","grey"), ncol=4, bty="n", xpd = NA)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.