R/ccir_timeseries_exploitation_plots_model_comparison.r

Defines functions ccir_timeseries_exploitation_plots_model_comparison

#' @export

ccir_timeseries_exploitation_plots_model_comparison <- function(x, y, xrange = NULL, running.median =T ,  running.length = 3,fname = NULL,bio.project ='bio.lobster') {
	#x is output from ccir_collapse_summary 
	# both sexes same plot
	lff = x$LFA[1]
	if(is.null(fname)) fname = paste('TS.exploitation.Compared',lff,x$Grid[1],'png',sep=".")	
	if(is.null(xrange)) xr = range(x$Yr)
	yr = c(0,1)
	fdir = file.path(project.figuredirectory(bio.project),'ccir')
	if(!dir.exists(fdir)) dir.create(fdir,recursive=T, showWarnings=F)

	if(grepl(351,x$Grid[1])) Main = 'LFA 27 South'
	if(grepl(356,x$Grid[1])) Main = 'LFA 27 North'
	if(grepl(341,x$Grid[1])) Main = 'LFA 29'
	if(grepl(345,x$Grid[1])) Main = 'LFA 30'
	if(grepl(337,x$Grid[1])) Main = 'LFA 31A'
	if(grepl(332,x$Grid[1])) Main = 'LFA 31B'
	if(grepl(323,x$Grid[1])) Main = 'LFA 32'
	if(grepl(301,x$Grid[1])) Main = 'LFA 33 West'
	if(grepl(313,x$Grid[1])) Main = 'LFA 33 East'

	xlab = 'Year'
	ylab = 'Exploitation Index'

		with(x,{
	Yr = Yr
	plot(Yr,ERfm,xlab=xlab,ylab=ylab,xlim=xr,ylim=yr,type='p',pch=16,col=1)
	arrows(x0 = Yr,y0 = ERfm,y1 = ERfu,length=0,lwd=1,col=1)
	arrows(x0 = Yr,y0 = ERfm,y1 = ERfl,length=0,lwd=1,col=1)
		  })
	
	with(y,{
	Yr = Yr+0.3
	points(Yr,ERfm,xlab=xlab,pch=17,col=2)
	arrows(x0 = Yr,y0 = ERfm,y1 = ERfu,length=0,lwd=1,col=2)
	arrows(x0 = Yr,y0 = ERfm,y1 = ERfl,length=0,lwd=1,col=2)
		  })
	
	title(Main)
	legend('bottomright',legend=c('Cumulative Monitoring','Cumulative Landings'),pch=c(16,17),col=c(1,2),bty='n',cex=0.75)
	savePlot(file.path(fdir,fname),type='png')

}
AMCOOK/bio.ccir documentation built on Sept. 11, 2023, 9:48 a.m.