From 0ffe1f343924644b6ca8f4a89c3d5b281c8c03be Mon Sep 17 00:00:00 2001 From: Mike Litzow Date: Thu, 13 Jun 2019 10:42:12 -0800 Subject: [PATCH 1/6] Adding EBS recruitment time series. --- data/ebs.biol.data.csv | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 data/ebs.biol.data.csv diff --git a/data/ebs.biol.data.csv b/data/ebs.biol.data.csv new file mode 100644 index 0000000..06bfdf2 --- /dev/null +++ b/data/ebs.biol.data.csv @@ -0,0 +1,57 @@ +year,yellowfin,turbot,flathead.sole,pollock +1960,,46073 ,, +1961,,82675 ,, +1962,,185807 ,, +1963,,437867 ,, +1964,733 ,484027 ,"455,615 ","6,294" +1965,749 ,204888 ,"435,985 ","20,951" +1966,"1,568 ",85070 ,"422,282 ","15,011" +1967,"2,395 ",44596 ,"418,335 ","25,590" +1968,"2,451 ",29672 ,"427,371 ","22,171" +1969,"3,227 ",24010 ,"448,528 ","26,244" +1970,"3,581 ",23147 ,"470,738 ","23,562" +1971,"2,817 ",26270 ,"476,659 ","14,401" +1972,"1,951 ",35638 ,"476,513 ","11,755" +1973,"2,620 ",59529 ,"427,138 ","27,009" +1974,"3,078 ",119004 ,"501,793 ","19,772" +1975,"2,027 ",209981 ,"609,171 ","16,758" +1976,"2,551 ",147543 ,"621,030 ","12,831" +1977,"1,670 ",93480 ,"558,901 ","13,276" +1978,"1,067 ",49205 ,"804,832 ","24,458" +1979,"2,065 ",17637 ,"1,065,140 ","58,151" +1980,"1,541 ",6022 ,"1,223,000 ","25,871" +1981,"4,464 ",1025 ,"2,262,170 ","29,475" +1982,827 ,1999 ,"976,982 ","16,662" +1983,"3,697 ",3289 ,"702,171 ","50,955" +1984,"1,278 ",6185 ,"1,352,310 ","14,281" +1985,982 ,20233 ,"2,121,820 ","34,580" +1986,"1,341 ",5317 ,"919,482 ","14,019" +1987,"1,837 ",5756 ,"2,409,590 ","7,524" +1988,"1,836 ",5897 ,"579,668 ","5,573" +1989,917 ,15803 ,"1,063,110 ","10,770" +1990,"1,030 ",3848 ,"1,202,660 ","47,657" +1991,"2,285 ",1131 ,"1,032,960 ","25,052" +1992,"1,361 ",743 ,"1,003,370 ","22,026" +1993,"1,148 ",606 ,"795,886 ","45,352" +1994,"1,156 ",954 ,"771,220 ","15,169" +1995,"2,850 ",3771 ,"693,230 ","10,371" +1996,"1,231 ",1612 ,"1,207,050 ","22,524" +1997,"1,020 ",1641 ,"1,154,200 ","30,739" +1998,"1,249 ",2145 ,"1,049,860 ","15,088" +1999,"1,767 ",8332 ,"751,622 ","16,347" +2000,"1,124 ",9648 ,"788,530 ","25,565" +2001,"1,547 ",11358 ,"1,095,690 ","34,834" +2002,"1,503 ",1677 ,"1,362,720 ","23,412" +2003,"2,388 ",614 ,"1,275,090 ","14,270" +2004,"1,042 ",547 ,"333,892 ","6,451" +2005,"1,258 ",801 ,"819,649 ","4,629" +2006,"1,607 ",7292 ,"737,612 ","11,769" +2007,"1,446 ",22137 ,"555,717 ","25,225" +2008,"1,550 ",48122 ,"766,015 ","13,623" +2009,"1,947 ",33061 ,"721,013 ","51,287" +2010,"1,482 ",6103 ,"489,730 ","21,394" +2011,,4003 ,"1,828,830 ","12,826" +2012,,1904 ,"714,452 ","11,188" +2013,,2430 ,"1,429,300 ","56,864" +2014,,2063 ,"1,613,410 ","42,237" +2015,,2458 ,,"12,693" \ No newline at end of file From 809e2d1f58257e43e5b1bee8ae11ab7fabe66290 Mon Sep 17 00:00:00 2001 From: Mike Litzow Date: Thu, 13 Jun 2019 11:15:11 -0800 Subject: [PATCH 2/6] Adding EBS recruitment time series. --- code/biology era regression hier.R | 23 +++++++++++++++++++++-- data/.DS_Store | Bin 0 -> 6148 bytes 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 data/.DS_Store diff --git a/code/biology era regression hier.R b/code/biology era regression hier.R index 249c673..3c11985 100644 --- a/code/biology era regression hier.R +++ b/code/biology era regression hier.R @@ -40,7 +40,7 @@ npgo2 <- rollapply(win.npgo, 2, mean, align="right", fill=NA) pdo2 <- rollapply(win.pdo, 2, mean, align="right", fill=NA) names(pdo2) <- 1900:2019 -# load three "non-salmon" data sets: GOA crustaceans/fish, Farallon seabirds, CalCOFI ichthyo +# load four "non-salmon" data sets: EBS groundfish recruitment, GOA crustaceans/fish, Farallon seabirds, CalCOFI ichthyo dat <- read.csv("data/farallon.sbrd.biol.csv", row.names = 1) # add era term dat$era <- as.factor(ifelse(dat$year <= 1988, 1, 2)) @@ -76,7 +76,6 @@ m2 = dplyr::group_by(melted, variable) %>% m2$system <- "CalCOFI ichthyoplankton" ######### - dat <- read.csv("data/goa.biol.csv") colnames(dat)[1] <- "year" dat$era <- as.factor(ifelse(dat$year <= 1988, 1, 2)) @@ -93,6 +92,26 @@ m3 = dplyr::group_by(melted, variable) %>% mutate(scale_x = scale(value)) m3$system <- "GOA fish & crustaceans" +####### +dat <- read.csv("data/ebs.biol.data.csv") + +dat$era <- as.factor(ifelse(dat$year <= 1988, 1, 2)) + +# and pdo/npgo +dat$pdo <- win.pdo[match(dat$year, names(win.pdo))] +dat$npgo <- win.npgo[match(dat$year, names(win.npgo))] + +# reshape with year, era, and pdo and npgo as the grouping variables +melted <- melt(dat, id.vars = c("year","pdo","era","npgo")) +melted$variable_era = paste0(melted$era,melted$variable) +melted$value <- as.numeric(melted$value) + +# standardize all the time series by variable -- so slopes are on same scale +m4 = dplyr::group_by(melted, variable) %>% + mutate(scale_x = scale(value)) +m3$system <- "GOA fish & crustaceans" + + ####### # combine diff --git a/data/.DS_Store b/data/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Thu, 13 Jun 2019 12:25:49 -0800 Subject: [PATCH 3/6] New region labels, nuked old density plots, save model data. --- code/biology era regression hier.R | 43 +++++++++++------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/code/biology era regression hier.R b/code/biology era regression hier.R index 3c11985..802276c 100644 --- a/code/biology era regression hier.R +++ b/code/biology era regression hier.R @@ -55,7 +55,7 @@ melted$variable_era = paste0(melted$era,melted$variable) # standardize all the time series by variable -- so slopes are on same scale m1 = dplyr::group_by(melted, variable) %>% mutate(scale_x = scale(value)) -m1$system <- "Farallon seabirds" +m1$system <- "Central California Current" #### # CalCOFI @@ -73,7 +73,7 @@ melted$variable_era = paste0(melted$era,melted$variable) # standardize all the time series by variable -- so slopes are on same scale m2 = dplyr::group_by(melted, variable) %>% mutate(scale_x = scale(value)) -m2$system <- "CalCOFI ichthyoplankton" +m2$system <- "Southern California Current" ######### dat <- read.csv("data/goa.biol.csv") @@ -90,7 +90,7 @@ melted$variable_era = paste0(melted$era,melted$variable) # standardize all the time series by variable -- so slopes are on same scale m3 = dplyr::group_by(melted, variable) %>% mutate(scale_x = scale(value)) -m3$system <- "GOA fish & crustaceans" +m3$system <- "Gulf of Alaska" ####### dat <- read.csv("data/ebs.biol.data.csv") @@ -109,13 +109,13 @@ melted$value <- as.numeric(melted$value) # standardize all the time series by variable -- so slopes are on same scale m4 = dplyr::group_by(melted, variable) %>% mutate(scale_x = scale(value)) -m3$system <- "GOA fish & crustaceans" +m4$system <- "Bering Sea" ####### # combine -melted <- rbind(m1, m2, m3) +melted <- rbind(m1, m2, m3, m4) melted$year <- as.numeric(melted$year) melted$variable <- as.factor(melted$variable) melted$variable_era <- as.factor(melted$variable_era) @@ -191,21 +191,17 @@ for(s in levels.syst) { } # order the systems north-south -model.data$order <- ifelse(model.data$system=="GOA fish & crustaceans", 1, - ifelse(model.data$system=="Farallon seabirds", 2, 3)) +model.data$order <- ifelse(model.data$system=="Bering Sea", 1, + ifelse(model.data$system=="Gulf of Alaska", 2, + ifelse(model.data$system=="Central California Current"), 3, 4)) model.data$system <- reorder(model.data$system, model.data$order) cb <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7") pdo.data <- model.data -pdo.plot <- ggplot(pdo.data, aes(ratio/100)) + # just removing % for now - theme_linedraw() + - geom_density(fill=cb[3]) + xlab("Avg ratio: Era 1 slope / Era 2 slope") + - facet_wrap(~system, ncol=1) + - xlim(c(0,2)) + - geom_vline(xintercept = 1)+ - ggtitle("a) PDO") +# save for future reference +write.csv(pdo.data, "models/pdo_biology_model_data.csv") ################# ## and the same thing for npgo @@ -274,24 +270,15 @@ for(s in levels.syst) { } # order the systems north-south -model.data$order <- ifelse(model.data$system=="GOA fish & crustaceans", 1, - ifelse(model.data$system=="Farallon seabirds", 2, 3)) +model.data$order <- ifelse(model.data$system=="Bering Sea", 1, + ifelse(model.data$system=="Gulf of Alaska", 2, + ifelse(model.data$system=="Central California Current"), 3, 4)) model.data$system <- reorder(model.data$system, model.data$order) npgo.data <- model.data -npgo.plot <- ggplot(npgo.data, aes(ratio/100)) + - theme_linedraw() + - geom_density(fill=cb[3]) + xlab("Avg ratio: Era 1 slope / Era 2 slope") + - facet_wrap(~system, ncol=1) + - geom_vline(xintercept=1) + - xlim(c(0,4.5)) + - ggtitle("b) NPGO") - -png("biol regression change pdo-npgo slope.png", 7, 7, units="in", res=300) -ggarrange(pdo.plot, npgo.plot, ncol=2) -dev.off() - +# save for future reference +write.csv(npgo.data, "models/npgo_biology_model_data.csv") # Caterpillar Plot =============================== # Helper Functions From 978cdf1b9a5b01f18753a73d1e5985dc55f60478 Mon Sep 17 00:00:00 2001 From: Mike Litzow Date: Fri, 14 Jun 2019 17:19:47 -0800 Subject: [PATCH 4/6] Uniform use of 2-year smoothe pdo/npgo througout. --- code/biology era regression hier.R | 57 ++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/code/biology era regression hier.R b/code/biology era regression hier.R index 802276c..1b7a5fb 100644 --- a/code/biology era regression hier.R +++ b/code/biology era regression hier.R @@ -36,18 +36,28 @@ npgo$win.yr <- ifelse(npgo$month %in% 11:12, npgo$Year+1, npgo$Year) win.npgo <- tapply(npgo$value, npgo$win.yr, mean) # and smoothed (2yr) values of each -npgo2 <- rollapply(win.npgo, 2, mean, align="right", fill=NA) -pdo2 <- rollapply(win.pdo, 2, mean, align="right", fill=NA) -names(pdo2) <- 1900:2019 +win.npgo <- rollapply(win.npgo, 2, mean, align="right", fill=NA) +names(win.npgo) <- 1950:2019 +win.pdo <- rollapply(win.pdo, 2, mean, align="right", fill=NA) +names(win.odo) <- 1900:2019 # load four "non-salmon" data sets: EBS groundfish recruitment, GOA crustaceans/fish, Farallon seabirds, CalCOFI ichthyo dat <- read.csv("data/farallon.sbrd.biol.csv", row.names = 1) + +# examine distributions +look <- dat %>% + gather(key, value, -year) + +ggplot(look, aes(value)) + + geom_histogram() + + facet_wrap(~key, scales="free") + # add era term dat$era <- as.factor(ifelse(dat$year <= 1988, 1, 2)) # and pdo/npgo -dat$pdo <- pdo2[match(dat$year, names(pdo2))] -dat$npgo <- npgo2[match(dat$year, names(npgo2))] +dat$pdo <- win.pdo[match(dat$year, names(win.pdo))] +dat$npgo <- win.npgo[match(dat$year, names(win.npgo))] # reshape with year, era, and pdo and npgo as the grouping variables melted <- melt(dat, id.vars = c("year","pdo","era","npgo")) @@ -61,11 +71,19 @@ m1$system <- "Central California Current" # CalCOFI dat <- read.csv("data/calcofi.biol.csv", row.names=1) +# examine distributions +look <- dat %>% + gather(key, value, -year) + +ggplot(look, aes(value)) + + geom_histogram() + + facet_wrap(~key, scales="free") + dat$era <- as.factor(ifelse(dat$year <= 1988, 1, 2)) # and pdo/npgo -dat$pdo <- pdo2[match(dat$year, names(pdo2))] -dat$npgo <- npgo2[match(dat$year, names(npgo2))] +dat$pdo <- win.pdo[match(dat$year, names(win.pdo))] +dat$npgo <- win.npgo[match(dat$year, names(win.npgo))] # reshape with year, era, and pdo and npgo as the grouping variables melted <- melt(dat, id.vars = c("year","pdo","era","npgo")) @@ -78,6 +96,15 @@ m2$system <- "Southern California Current" ######### dat <- read.csv("data/goa.biol.csv") colnames(dat)[1] <- "year" + +# examine distributions +look <- dat %>% + gather(key, value, -year) + +ggplot(look, aes(value)) + + geom_histogram() + + facet_wrap(~key, scales="free") + dat$era <- as.factor(ifelse(dat$year <= 1988, 1, 2)) # and pdo/npgo @@ -94,6 +121,15 @@ m3$system <- "Gulf of Alaska" ####### dat <- read.csv("data/ebs.biol.data.csv") +dat[,2:5] <- sqrt(dat[,2:5]) + +# examine distributions +look <- dat %>% + gather(key, value, -year) + +ggplot(look, aes(value)) + + geom_histogram() + + facet_wrap(~key, scales="free") dat$era <- as.factor(ifelse(dat$year <= 1988, 1, 2)) @@ -193,11 +229,9 @@ for(s in levels.syst) { # order the systems north-south model.data$order <- ifelse(model.data$system=="Bering Sea", 1, ifelse(model.data$system=="Gulf of Alaska", 2, - ifelse(model.data$system=="Central California Current"), 3, 4)) + ifelse(model.data$system=="Central California Current", 3, 4))) model.data$system <- reorder(model.data$system, model.data$order) -cb <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7") - pdo.data <- model.data # save for future reference @@ -269,10 +303,11 @@ for(s in levels.syst) { dev.off() } + # order the systems north-south model.data$order <- ifelse(model.data$system=="Bering Sea", 1, ifelse(model.data$system=="Gulf of Alaska", 2, - ifelse(model.data$system=="Central California Current"), 3, 4)) + ifelse(model.data$system=="Central California Current", 3, 4))) model.data$system <- reorder(model.data$system, model.data$order) npgo.data <- model.data From db1005d28dc7f96d9e1cc692922d6c656233c84b Mon Sep 17 00:00:00 2001 From: Mike Litzow Date: Fri, 14 Jun 2019 19:11:58 -0800 Subject: [PATCH 5/6] Fixed EBS biology data. --- data/ebs.biol.data.csv | 114 ++++++++++++++++++++--------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/data/ebs.biol.data.csv b/data/ebs.biol.data.csv index 06bfdf2..ce593d6 100644 --- a/data/ebs.biol.data.csv +++ b/data/ebs.biol.data.csv @@ -1,57 +1,57 @@ -year,yellowfin,turbot,flathead.sole,pollock -1960,,46073 ,, -1961,,82675 ,, -1962,,185807 ,, -1963,,437867 ,, -1964,733 ,484027 ,"455,615 ","6,294" -1965,749 ,204888 ,"435,985 ","20,951" -1966,"1,568 ",85070 ,"422,282 ","15,011" -1967,"2,395 ",44596 ,"418,335 ","25,590" -1968,"2,451 ",29672 ,"427,371 ","22,171" -1969,"3,227 ",24010 ,"448,528 ","26,244" -1970,"3,581 ",23147 ,"470,738 ","23,562" -1971,"2,817 ",26270 ,"476,659 ","14,401" -1972,"1,951 ",35638 ,"476,513 ","11,755" -1973,"2,620 ",59529 ,"427,138 ","27,009" -1974,"3,078 ",119004 ,"501,793 ","19,772" -1975,"2,027 ",209981 ,"609,171 ","16,758" -1976,"2,551 ",147543 ,"621,030 ","12,831" -1977,"1,670 ",93480 ,"558,901 ","13,276" -1978,"1,067 ",49205 ,"804,832 ","24,458" -1979,"2,065 ",17637 ,"1,065,140 ","58,151" -1980,"1,541 ",6022 ,"1,223,000 ","25,871" -1981,"4,464 ",1025 ,"2,262,170 ","29,475" -1982,827 ,1999 ,"976,982 ","16,662" -1983,"3,697 ",3289 ,"702,171 ","50,955" -1984,"1,278 ",6185 ,"1,352,310 ","14,281" -1985,982 ,20233 ,"2,121,820 ","34,580" -1986,"1,341 ",5317 ,"919,482 ","14,019" -1987,"1,837 ",5756 ,"2,409,590 ","7,524" -1988,"1,836 ",5897 ,"579,668 ","5,573" -1989,917 ,15803 ,"1,063,110 ","10,770" -1990,"1,030 ",3848 ,"1,202,660 ","47,657" -1991,"2,285 ",1131 ,"1,032,960 ","25,052" -1992,"1,361 ",743 ,"1,003,370 ","22,026" -1993,"1,148 ",606 ,"795,886 ","45,352" -1994,"1,156 ",954 ,"771,220 ","15,169" -1995,"2,850 ",3771 ,"693,230 ","10,371" -1996,"1,231 ",1612 ,"1,207,050 ","22,524" -1997,"1,020 ",1641 ,"1,154,200 ","30,739" -1998,"1,249 ",2145 ,"1,049,860 ","15,088" -1999,"1,767 ",8332 ,"751,622 ","16,347" -2000,"1,124 ",9648 ,"788,530 ","25,565" -2001,"1,547 ",11358 ,"1,095,690 ","34,834" -2002,"1,503 ",1677 ,"1,362,720 ","23,412" -2003,"2,388 ",614 ,"1,275,090 ","14,270" -2004,"1,042 ",547 ,"333,892 ","6,451" -2005,"1,258 ",801 ,"819,649 ","4,629" -2006,"1,607 ",7292 ,"737,612 ","11,769" -2007,"1,446 ",22137 ,"555,717 ","25,225" -2008,"1,550 ",48122 ,"766,015 ","13,623" -2009,"1,947 ",33061 ,"721,013 ","51,287" -2010,"1,482 ",6103 ,"489,730 ","21,394" -2011,,4003 ,"1,828,830 ","12,826" -2012,,1904 ,"714,452 ","11,188" -2013,,2430 ,"1,429,300 ","56,864" -2014,,2063 ,"1,613,410 ","42,237" -2015,,2458 ,,"12,693" \ No newline at end of file +year,yellowfin,turbot,flathead.sole,pollock +1960,,46073,, +1961,,82675,, +1962,,185807,, +1963,,437867,, +1964,733,484027,455615,6294 +1965,749,204888,435985,20951 +1966,1568,85070,422282,15011 +1967,2395,44596,418335,25590 +1968,2451,29672,427371,22171 +1969,3227,24010,448528,26244 +1970,3581,23147,470738,23562 +1971,2817,26270,476659,14401 +1972,1951,35638,476513,11755 +1973,2620,59529,427138,27009 +1974,3078,119004,501793,19772 +1975,2027,209981,609171,16758 +1976,2551,147543,621030,12831 +1977,1670,93480,558901,13276 +1978,1067,49205,804832,24458 +1979,2065,17637,1065140,58151 +1980,1541,6022,1223000,25871 +1981,4464,1025,2262170,29475 +1982,827,1999,976982,16662 +1983,3697,3289,702171,50955 +1984,1278,6185,1352310,14281 +1985,982,20233,2121820,34580 +1986,1341,5317,919482,14019 +1987,1837,5756,2409590,7524 +1988,1836,5897,579668,5573 +1989,917,15803,1063110,10770 +1990,1030,3848,1202660,47657 +1991,2285,1131,1032960,25052 +1992,1361,743,1003370,22026 +1993,1148,606,795886,45352 +1994,1156,954,771220,15169 +1995,2850,3771,693230,10371 +1996,1231,1612,1207050,22524 +1997,1020,1641,1154200,30739 +1998,1249,2145,1049860,15088 +1999,1767,8332,751622,16347 +2000,1124,9648,788530,25565 +2001,1547,11358,1095690,34834 +2002,1503,1677,1362720,23412 +2003,2388,614,1275090,14270 +2004,1042,547,333892,6451 +2005,1258,801,819649,4629 +2006,1607,7292,737612,11769 +2007,1446,22137,555717,25225 +2008,1550,48122,766015,13623 +2009,1947,33061,721013,51287 +2010,1482,6103,489730,21394 +2011,,4003,1828830,12826 +2012,,1904,714452,11188 +2013,,2430,1429300,56864 +2014,,2063,1613410,42237 +2015,,2458,,12693 \ No newline at end of file From eebcf04fdab7c2af950b7ae5b53de387c7144a57 Mon Sep 17 00:00:00 2001 From: Mike Litzow Date: Fri, 14 Jun 2019 19:12:52 -0800 Subject: [PATCH 6/6] Tweaked plot. --- code/biology era regression hier.R | 47 +++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/code/biology era regression hier.R b/code/biology era regression hier.R index 1b7a5fb..c678fdf 100644 --- a/code/biology era regression hier.R +++ b/code/biology era regression hier.R @@ -39,7 +39,7 @@ win.npgo <- tapply(npgo$value, npgo$win.yr, mean) win.npgo <- rollapply(win.npgo, 2, mean, align="right", fill=NA) names(win.npgo) <- 1950:2019 win.pdo <- rollapply(win.pdo, 2, mean, align="right", fill=NA) -names(win.odo) <- 1900:2019 +names(win.pdo) <- 1900:2019 # load four "non-salmon" data sets: EBS groundfish recruitment, GOA crustaceans/fish, Farallon seabirds, CalCOFI ichthyo dat <- read.csv("data/farallon.sbrd.biol.csv", row.names = 1) @@ -187,7 +187,7 @@ for(s in levels.syst) { pars = rstan::extract(mod,permuted=TRUE) model.data = rbind(model.data, - data.frame(system=unique(melted$system)[s], + data.frame(system=s, ratio=100*exp(pars$mu_ratio))) temp$pred = apply(pars$pred,2,mean) @@ -226,10 +226,16 @@ for(s in levels.syst) { } +# add a placeholder +placeholder <- data.frame(system="Northern California Current", ratio=NA) +model.data <- rbind(model.data, placeholder) + # order the systems north-south model.data$order <- ifelse(model.data$system=="Bering Sea", 1, ifelse(model.data$system=="Gulf of Alaska", 2, - ifelse(model.data$system=="Central California Current", 3, 4))) + ifelse(model.data$system=="Northern California Current", 3, + ifelse(model.data$system=="Central California Current", 4, 5)))) + model.data$system <- reorder(model.data$system, model.data$order) pdo.data <- model.data @@ -303,11 +309,16 @@ for(s in levels.syst) { dev.off() } +# add a placeholder +placeholder <- data.frame(system="Northern California Current", ratio=NA) +model.data <- rbind(model.data, placeholder) # order the systems north-south model.data$order <- ifelse(model.data$system=="Bering Sea", 1, ifelse(model.data$system=="Gulf of Alaska", 2, - ifelse(model.data$system=="Central California Current", 3, 4))) + ifelse(model.data$system=="Northern California Current", 3, + ifelse(model.data$system=="Central California Current", 4, 5)))) + model.data$system <- reorder(model.data$system, model.data$order) npgo.data <- model.data @@ -327,25 +338,35 @@ head(pdo.data) npgo.data$var <- "NPGO" pdo.data$var <- "PDO" all.data <- rbind(pdo.data, npgo.data) +all.data$var.order <- ifelse(all.data$var=="PDO", 1, 2) +all.data$var <- reorder(all.data$var, all.data$var.order) +all.data$log.ratio <- log(all.data$ratio/100, 10) -cat.plt <- ggplot(all.data, aes(x=system, y=ratio/100, fill=system)) + +# colorblind... +cb <- c("#000000", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7") + +biol.plt <- ggplot(all.data, aes(x=reorder(system, desc(system)), y=log.ratio, fill=system)) + theme_linedraw() + + scale_fill_manual(values=cb[c(6,3,4,2,8)], + labels=c("Bering Sea", "Gulf of Alaska", "Central Cal. Curr.", "Southern Cal. Curr.")) + # scale_fill_colorblind() + - scale_fill_tableau() + + # scale_fill_tableau() + # scale_fill_brewer(c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")) + # geom_eye() + - + geom_violin(alpha = 0.75, lwd=0.1, scale='width') + stat_summary(fun.y="q.95", colour="black", geom="line", lwd=0.75) + stat_summary(fun.y="q.50", colour="black", geom="line", lwd=1.5) + stat_summary(fun.y="median", colour="black", size=2, geom="point", pch=21) + facet_wrap(~var, ncol=1) + - ylab("Avg ratio: Era 1 slope / Era 2 slope") + - theme(axis.text.y = element_blank()) + - geom_hline(aes(yintercept=1), color="red", linetype="dotted", size=1) + - coord_flip(ylim=c(0,7)) - -cat.plt + ylab("Log ratio: Era 1 slope / Era 2 slope") + + theme(axis.text.y = element_blank(), axis.title.y = element_blank(), axis.ticks.y = element_line(size=0), + legend.title = element_blank(), legend.position = c(0.15, 0.15)) + + geom_hline(aes(yintercept=0), color="red", linetype="dotted", size=1) + + coord_flip(ylim=c()) + + +biol.plt ggsave("biol regression change pdo-npgo slope_cater.png", plot=cat.plt, height=7, width=7, units="in", dpi=300)