Skip to content

Commit 8213908

Browse files
-Add part in beginning of stockplotr section that mentions the input is a standardized output
-Interactive is not default to FALSE – change this note in the code chunk for the customization -“Inhertied from a ggplot2” to “Inhertied from a ggplot2 geom" -Change tables_dir → figures_dir into rda export sec -Add code chunk to run create_figure_doc
1 parent 16b0062 commit 8213908

2 files changed

Lines changed: 59 additions & 29 deletions

File tree

Curriculum/Day_3/day_3.qmd

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Break for issues
7070

7171
This package is an ongoing process to gather contributions in order to expand the number of pre-made tables and figures that can be incorporated into a stock assessment report. All objects are intended to be generalized and not specific to any region.
7272

73-
{stockplotr} also contains `convert_output()`: the function used to convert model results into a standardize output (as explained in a [previous section](https://nmfs-ost.github.io/workflows-workshop/Curriculum/Day_2/day_2.html#stockplotrconvert_output)).
73+
{stockplotr} also contains `convert_output()`: the function used to convert model results into a standardized output (as explained in a [previous section](https://nmfs-ost.github.io/workflows-workshop/Curriculum/nsaw.html#stockplotrconvert_output)). This standardized output is the input for the {stockplotr} plotting functions, below (the `dat` argument).
7474

7575
The following table contains figures and tables that are available in {stockplotr}:
7676

@@ -99,18 +99,18 @@ Each automated function returns either a `ggplot2` object (figure) or `gt` objec
9999

100100
Run the example below. It should result in a line graph showing biomass over time, including a reference line for the biomass unfished.
101101

102-
```{r}
102+
```{r eval = FALSE}
103103
stockplotr::plot_biomass(
104-
dat = petrale,
105-
geom = "line",
106-
group = NULL,
107-
facet = NULL,
108-
ref_line = "unfished",
109-
unit_label = "mt",
110-
scale_amount = 1,
111-
relative = FALSE,
112-
interactive = TRUE,
113-
module = NULL
104+
dat = petrale, # dataset
105+
geom = "line", # show a line graph
106+
group = NULL, # don't group by sex, fleet, etc.
107+
facet = NULL, # not faceting by any variable
108+
ref_line = "unfished", # set reference line at unfished
109+
unit_label = "mt", # unit label: metric tons
110+
scale_amount = 1, # do not scale biomass
111+
relative = FALSE, # show biomass, NOT relative biomass
112+
interactive = TRUE, # prompt user for MODULE_NAME in console
113+
module = NULL # MODULE_NAME not specified here
114114
)
115115
```
116116

@@ -136,20 +136,24 @@ stockplotr::plot_biomass(
136136
geom = "line",
137137
group = NULL,
138138
facet = NULL,
139-
ref_line = c("target" = 260),
139+
ref_line = c("target" = 260), # changed from "unfished"
140140
unit_label = "mt",
141141
scale_amount = 1,
142142
relative = FALSE,
143-
# interactive = TRUE,
144-
module = "TIME_SERIES"
143+
interactive = FALSE, # changed from TRUE
144+
module = "TIME_SERIES" # indicate module name here
145145
)
146146
```
147147

148148
![](images/day3_ex_plt2.png)
149149

150150
#### Plot relative biomass and change the size of the line
151151

152-
In this example, we still are bypassing module selection and we are automatically extracting the reference line value from the data. However, now we are using this reference value to plot relative biomass and changing the linewidth to 2 (an argument inherited from `ggplot2`).
152+
In this example, we still are bypassing module selection and we are automatically extracting the reference line value from the data. However, now we are using this reference value to plot relative biomass and changing the linewidth to 2 (an argument inherited from `ggplot2::geom_line()`).
153+
154+
::: {.callout-note}
155+
If you were plotting a scatterplot (`geom = 'point'`) or area plot (`geom = 'area'`), you could add arguments associated with `geom_point()` and `geom_area()`, respectively.
156+
:::
153157

154158
```{r}
155159
stockplotr::plot_biomass(
@@ -160,10 +164,10 @@ stockplotr::plot_biomass(
160164
ref_line = c("target" = 260),
161165
unit_label = "mt",
162166
scale_amount = 1,
163-
relative = TRUE,
164-
# interactive = TRUE,
167+
relative = TRUE, # changed from FALSE
168+
interactive = FALSE,
165169
module = "TIME_SERIES",
166-
linewidth = 2
170+
linewidth = 2 # increase width of lines
167171
)
168172
```
169173

@@ -183,11 +187,11 @@ stockplotr::plot_biomass(
183187
geom = "line",
184188
group = "none",
185189
facet = NULL,
186-
ref_line = NULL,
190+
ref_line = NULL, # changed from c("target" = 260)
187191
unit_label = "mt",
188192
scale_amount = 1,
189193
relative = FALSE,
190-
# interactive = TRUE,
194+
interactive = FALSE,
191195
module = "TIME_SERIES"
192196
)
193197
```
@@ -212,7 +216,7 @@ stockplotr::plot_biomass(
212216
unit_label = "mt",
213217
scale_amount = 1,
214218
relative = FALSE,
215-
# interactive = TRUE,
219+
interactive = FALSE,
216220
module = "TIME_SERIES"
217221
) +
218222
ggplot2::geom_vline(xintercept = 2005, linetype = "dashed", color = "red")
@@ -315,7 +319,7 @@ stockplotr::plot_biomass(
315319
unit_label = "mt",
316320
module = "TIME_SERIES",
317321
make_rda = TRUE,
318-
tables_dir = getwd()
322+
figures_dir = getwd()
319323
)
320324
```
321325

@@ -434,6 +438,17 @@ Adding figures entails nearly the same process as described for tables. The only
434438
1. Figures will involve captions and *alternative text*, whereas tables only require captions
435439
2. Figures do not require the option to be rotated or split across pages.
436440

441+
```{r}
442+
#| label: add-figures
443+
#| eval: false
444+
#| warning: false
445+
#| messages: false
446+
create_figures_doc(
447+
subdir = fs::path(getwd(), "report"),
448+
figures_dir = getwd()
449+
)
450+
```
451+
437452
::: {.callout-note appearance="minimal"}
438453
Break for questions
439454
:::

Curriculum/nsaw.qmd

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ Learn about how to [call in previous reports](https://nmfs-ost.github.io/workflo
549549

550550
This package is an ongoing process to gather contributions in order to expand the number of pre-made tables and figures that can be incorporated into a stock assessment report. All objects are intended to be generalized and not specific to any region.
551551

552-
{stockplotr} also contains `convert_output()`: the function used to convert model results into a standardize output (as explained in a [previous section](https://nmfs-ost.github.io/workflows-workshop/Curriculum/nsaw.html#stockplotrconvert_output)).
552+
{stockplotr} also contains `convert_output()`: the function used to convert model results into a standardized output (as explained in a [previous section](https://nmfs-ost.github.io/workflows-workshop/Curriculum/nsaw.html#stockplotrconvert_output)). This standardized output is the input for the {stockplotr} plotting functions, below (the `dat` argument).
553553

554554
The following table contains figures and tables that are available in {stockplotr}:
555555

@@ -607,7 +607,7 @@ Here are some examples of how to customize the biomass figure:
607607

608608
#### Change the reference line to a specific value (e.g., 260)
609609

610-
In this example we are also telling the function which module to select in order to by-pass this step. We plan to remove grouping of some modules in the future.
610+
In this example we are also telling the function which module to select in order to by-pass this step. We plan to remove grouping of some modules in the future.
611611

612612
```{r eval = FALSE}
613613
stockplotr::plot_biomass(
@@ -619,7 +619,7 @@ stockplotr::plot_biomass(
619619
unit_label = "mt",
620620
scale_amount = 1,
621621
relative = FALSE,
622-
# interactive = TRUE, # commenting out this argument sets it to FALSE
622+
interactive = FALSE, # changed from TRUE
623623
module = "TIME_SERIES" # indicate module name here
624624
)
625625
```
@@ -628,7 +628,11 @@ stockplotr::plot_biomass(
628628

629629
#### Plot relative biomass and change the size of the line
630630

631-
In this example, we still are bypassing module selection and we are automatically extracting the reference line value from the data. However, now we are using this reference value to plot relative biomass and changing the linewidth to 2 (an argument inherited from `ggplot2`).
631+
In this example, we still are bypassing module selection and we are automatically extracting the reference line value from the data. However, now we are using this reference value to plot relative biomass and changing the linewidth to 2 (an argument inherited from `ggplot2::geom_line()`).
632+
633+
::: {.callout-note}
634+
If you were plotting a scatterplot (`geom = 'point'`) or area plot (`geom = 'area'`), you could add arguments associated with `geom_point()` and `geom_area()`, respectively.
635+
:::
632636

633637
```{r eval = FALSE}
634638
stockplotr::plot_biomass(
@@ -640,7 +644,7 @@ stockplotr::plot_biomass(
640644
unit_label = "mt",
641645
scale_amount = 1,
642646
relative = TRUE, # changed from FALSE
643-
# interactive = TRUE,
647+
interactive = FALSE,
644648
module = "TIME_SERIES",
645649
linewidth = 2 # increase width of lines
646650
)
@@ -704,7 +708,7 @@ stockplotr::plot_biomass(
704708
unit_label = "mt",
705709
module = "TIME_SERIES",
706710
make_rda = TRUE,
707-
tables_dir = getwd()
711+
figures_dir = getwd()
708712
)
709713
```
710714

@@ -795,6 +799,17 @@ Adding figures entails nearly the same process as described for tables. The only
795799
1. Figures will involve captions and *alternative text*, whereas tables only require captions
796800
2. Figures do not require the option to be rotated or split across pages.
797801

802+
```{r}
803+
#| label: add-figures
804+
#| eval: false
805+
#| warning: false
806+
#| messages: false
807+
create_figures_doc(
808+
subdir = fs::path(getwd(), "report"),
809+
figures_dir = getwd()
810+
)
811+
```
812+
798813
### Option 2: Manually adding tables/figures
799814

800815
::: {.callout-tip}

0 commit comments

Comments
 (0)