-
Notifications
You must be signed in to change notification settings - Fork 3
/
08-plotting_fisheries_data.Rmd
121 lines (101 loc) · 6.9 KB
/
08-plotting_fisheries_data.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Plotting Fisheries Data
```{r include=FALSE}
knitr::opts_chunk$set(warning = F, message = F, error = F)
```
This document will now walk you through how to make make some basic fisheries plots using the data frames you created in the previous analysis section and the `ggplot` plotting function. When using `ggplot`, first start with your data frame and initialize the ggplot by specifying the plot's *aesthetics* (variables) using `aes()`. Then use the `+` operation to add at least one *geometry* (type of plot, such as a scatter plot) and any additional features to the plot. To learn more about `ggplot`, the [Data Visualization with ggplot2 Cheat Sheet](https://www.rstudio.com/wp-content/uploads/2016/11/ggplot2-cheatsheet-2.1.pdf) is a very helpful resource, as is this [ggplot cookbook](http://www.cookbook-r.com/Graphs/).
## Plotting Landings
Let's plot a time series of annual landings data. We start with the annual landings data we made in the previous step, and then feed this into a ggplot.
```{r}
# Start with the annual_landings data frame you created in the last step
annual_landings %>%
# Initialize a ggplot of annual landings versus year
ggplot(aes(x=Year,y=Annual_Landings_kg)) +
# Tell ggplot that the plot type should be a scatter plot
geom_point() +
# Also add a line connecting the points
geom_line() +
# Change the y-axis title
ylab("Annual Landings [kg/year]") +
# Add figure title
ggtitle("Annual landings of Caesio cuning")
```
In this example, we are using `aes(x=Year, y=Annual_Landings_kg)` to specify that the we want to plot years on the x-axis and annual landings on the y-axis. We then want to visualize these variables with both a scatter plot (`geom_point()`) *and* a line plot (`geom_line()`) geometry.
It appears landings were going down between 2004 and 2011, but have been increasing since then. Again, you may be interested in looking across different gear types. To plot, we use ggplot's faceting functionality, which tells `ggplot` to divide up the data by a certain variable, `Gear` in this case, and make multiple similar plots. You can use the `facet_wrap()` function to accomplish this.
```{r}
# Start with the landings data frame
annual_gear_landings %>%
# First, group the data by year
group_by(Year,Gear) %>%
# Initialize a ggplot of annual landings versus year
ggplot(aes(x=Year,y=Annual_Landings_kg)) +
# Tell ggplot that the plot type should be a scatter plot
geom_point() +
# Also add a line connecting the points
geom_line() +
# Change the y-axis title
ylab("Normalized annual Landings [kg/year]") +
# Add figure title
ggtitle("Normalized annual landings of Caesio cuning") +
# This tells the figure to plot by all different gear types
facet_wrap(~Gear)
```
It now becomes clear that the recent increase in catch seems to be concentrated in speargun and trap fishing. Meanwhile, catch from muroami, a very destructive type of gear where nets are driven into the reef, has dropped to 0 since a ban of that gear in 2012 - a good sign that management regulation is working.
## Plotting CPUE
You may also be interested in plotting median catch-per-unit-effort (CPUE). You take your CPUE data frame made in the last step and feed it into ggplot.
```{r}
# Start with the CPUE data frame
cpue_data %>%
# Initialize a ggplot of median CPUE versus year
ggplot(aes(x=Year,y=Median_CPUE_kg_hour)) +
# Tell ggplot that the plot type should be a scatter plot
geom_point() +
# Also add a line connecting the points
geom_line() +
# Change the y-axis title
ylab("Median CPUE [kg/hour]") +
# Add figure title
ggtitle("Median CPUE for Caesio cuning")
```
CPUE appears to have increased significantly during the last years. This may be due to increasing abundance in the water, which would be a good thing, but may also be indicative of increased gear efficiency coinciding with the transition to traps and spearguns, which may be concerning.
## Plotting Length Frequency
Finally, let's first look at the length data from the catch, which gives an indication of the size structure and health of the population. Let's look at the length data for 2014, which is the most recent year of data available. We first filter the data to be only from 2014 using the `filter()` function. We then create a histogram of the length data, which shows how many individuals of each size class were measured in the catch. On the histogram, we'll also add a vertical line to show the length at which fish mature to get a sense of how sustainable the catch is - the catch should be composed mostly of mature fish. This information comes from the life history parameter data input file.
```{r}
# Start with the landings data frame
landings_data %>%
# Filter data to only look at length measurements from 2014
filter(Year == 2014) %>%
# Initialize ggplot of data using the length column
ggplot(aes(Length_cm)) +
# Tell ggplot that the plot type should be a histogram
geom_histogram() +
# Change x-axis label
xlab("Length [cm]") +
# Add figure title
ggtitle("Length histogram of Caesio cuning in the catch\nLength at 95% maturity shown as a red line.") +
# Add a red vertical line for m95, the length at which 95% of fish are mature. Any fish below this length may be immature. Use the m95 value defined in the previous section
geom_vline(aes(xintercept=m95),color="red")
```
You might also be interested in seeing how the size composition varies by gear type. You can recreate the figure above, but separate the histograms out by gear type using ggplot's "facet" function.
```{r}
# Start with the landings data frame
landings_data %>%
# Filter data to only look at length measurements from 2014
filter(Year == 2014) %>%
# Initialize ggplot of data using the length column
ggplot(aes(Length_cm)) +
# Tell ggplot that the plot type should be a histogram
geom_histogram() +
# Change x-axis label
xlab("Length [cm]") +
# Add figure title
ggtitle("Length histogram of Caesio cuning in the catch by gear type\nLength at 95% maturity shown as a red line.") +
# Add a red line for m95, the length at which 95% of fish are mature. Any fish below this length may be immature. Use the life_history_parameter data frame to get this value.
geom_vline(aes(xintercept=m95),color="red") +
# This tells the figure to plot by all different gear types, known as facetting
facet_wrap(~Gear)
```
It appears as if the size structure is about the same from each gear, although by far the most amount of fish are caught using speargun. Very few fish are caught using trolling.
These plots indicate a generally increasing catch, CPUE, and a healthy size structure. Our results demonstrate that the population is likely doing fairly well, and may be recovering since the 2012 ban of muroami fishing gear.
## Helpful Resources
+ [Data Visualization with ggplot2 Cheat Sheet](https://www.rstudio.com/wp-content/uploads/2016/11/ggplot2-cheatsheet-2.1.pdf)
+ [ggplot cookbook](http://www.cookbook-r.com/Graphs/)