acl_theme_set()
View source ↗On this page
Set the style, colors, typography, labels and layout defaults of all plots.
Usage
acl_theme_set(
base_theme = NULL,
font_family = NULL,
title_size = NULL,
title_hjust = NULL,
axis_title_size = NULL,
axis_text_size = NULL,
strip_text_size = NULL,
legend_text_size = NULL,
x_breaks = NULL,
x_expand = NULL,
line_color = NULL,
line_size = NULL,
point_size = NULL,
se_color = NULL,
se_alpha = NULL,
compare_colors = NULL,
compare_linetypes = NULL,
compare_line_size = NULL,
compare_point_size = NULL,
compare_se_alpha = NULL,
compare_legend_pos = NULL,
compare_facet_ncol = NULL,
compare_facet_scales = NULL,
titles = NULL,
xlab = NULL,
ylab = NULL,
palette = NULL,
point_color = NULL,
observed_color = NULL,
smooth_color = NULL,
hline_color = NULL,
low_col = NULL,
high_col = NULL,
style = NULL,
grid = NULL,
title_face = NULL,
title_color = NULL,
stock_color = NULL,
F_color = NULL,
recruitment_color = NULL,
catch_color = NULL,
bars = NULL,
y_zero = NULL,
strip = NULL,
legend_position = NULL,
axis_color = NULL,
...,
interval = NULL,
show_title = NULL,
x_angle = NULL
)
Arguments
| Argument | Default | Description |
|---|---|---|
base_theme | NULL | Character. Name of the base ggplot2 theme, one of "bw", "minimal", "classic", "gray", "grey", "light", "linedraw", "dark" and "void", with or without the "theme_" prefix. Any other value is an error. Letter case does not matter. |
font_family | NULL | Character. Font family of all text, which must be installed on the computer (default "sans"); "" uses the default font of the graphics device. |
title_size | NULL | Numeric. Size of the plot titles in pt (default 14). |
title_hjust | NULL | Numeric. Horizontal position of the titles, 0 for left, 0.5 for centered and 1 for right. The style sets it to 0 under "default" and 0.5 under "classic". |
axis_title_size | NULL | Numeric. Size of the axis titles in pt (default 12). |
axis_text_size | NULL | Numeric. Size of the axis tick labels in pt (default 10). |
strip_text_size | NULL | Numeric. Size of the panel labels in pt (default 10). |
legend_text_size | NULL | Numeric. Size of the legend text in pt (default 10). |
x_breaks | NULL | Numeric vector or NULL. Custom x-axis breaks. One setting serves time, age and length axes. A plot uses it only when at least one break lies within the range of its x axis; otherwise that plot chooses its breaks automatically. Calendar-year breaks therefore do not blank age or length axes. Pass NULL explicitly to restore automatically selected breaks; omitting the argument leaves the current setting unchanged. |
x_expand | NULL | Numeric vector of two numbers of zero or more, the share of the axis range added at each end of the x axis (default c(0.01, 0.01)). |
line_color | NULL | Character. Default line color of single-model plots. |
line_size | NULL | Numeric. Default line width of single-model plots (1 under the default style, 1.5 under "classic"). Figures with many panels use thinner lines unless a plot call gives line_size. |
point_size | NULL | Numeric. Default point size of all plots that draw points (2.5); |
se_color | NULL | Character. Default color of interval ribbons and error bars. NA draws intervals without a color, as |
se_alpha | NULL | Numeric. Default transparency of interval ribbons (0.3 under the default style, 0.2 under "classic"). Plot arguments set to NULL inherit this value; explicit alpha takes priority. Error bars are drawn opaque unless a plot call supplies se_alpha. |
compare_colors | NULL | Character vector of two colors, the first for model1 and the second for model2, with or without names, for example c("blue", "red"), c(ACL = "blue", ALSCL = "red") or c("M=0" = "steelblue", "M=0.5" = "tomato"). |
compare_linetypes | NULL | Character vector of two line types, the first for model1 and the second for model2, with or without names. |
compare_line_size | NULL | Numeric. Line width for comparison plots (0.9 under the default style, 1.2 under "classic"). |
compare_point_size | NULL | Numeric or NULL. Point size of the comparison plots. An explicit NULL clears it, and the comparison plots then inherit point_size. |
compare_se_alpha | NULL | Numeric. Transparency of the interval ribbons of comparison plots (0.25 under the default style, 0.15 under "classic"). |
compare_legend_pos | NULL | Character. Legend position of the comparison plots, "bottom" (default), "top", "left", "right", "none" or "inside" (inside the panel). Letter case does not matter. |
compare_facet_ncol | NULL | Integer or NULL. Facet columns of comparison plots. NULL (default) chooses the columns from the number of panels, as the single-model plots do; pass NULL explicitly to restore it. |
compare_facet_scales | NULL | Character. Facet scales of the comparison plots with panels, including the heat maps of |
titles | NULL | Named list. Override specific titles. The keys are listed in |
xlab | NULL | Named list. Override specific x-axis labels. |
ylab | NULL | Named list. Override specific y-axis labels. The default fishing mortality label gains the time basis of the fit, for example "(per year)" or "(per quarter)"; a customized |
palette | NULL | Character or NULL. Categorical palette, "default" (the palette of the default style) or one of the ggsci palettes "npg", "aaas", "nejm", "lancet" and "jama". Changing it resets the colors derived from the palette (line, interval, point, observation, smoother, comparison and heat map colors) and leaves the four quantity colors (stock_color, F_color, recruitment_color, catch_color) unchanged; set those to NULL to give the quantities the line color of the palette. Explicit color arguments in the same call take precedence. A call without arguments leaves the settings unchanged; use acl_theme_reset() to reset. Letter case does not matter. |
point_color | NULL | Character or NULL. Default color of points. |
observed_color | NULL | Character or NULL. Default color of observations. |
smooth_color | NULL | Character or NULL. Default color of smoothers and trend lines. |
hline_color | NULL | Character or NULL. Default color of reference lines, such as the zero line of residual plots. |
low_col | NULL | Character or NULL. Color of the low end of continuous heat maps. |
high_col | NULL | Character or NULL. Color of the high end of continuous heat maps. |
style | NULL | Character or NULL. A preset of the look of all plots, "default" or "classic". "classic" uses the npg palette, centered plain titles, lines for every series, y axes not forced to zero and grey facet strips. Setting a style replaces palette, grid, title_face, title_hjust, title_color, the four quantity colors, bars, y_zero, se_alpha, compare_se_alpha, strip, legend_position, axis_color, line_size, compare_line_size and the palette-derived colors with the values of the preset. Other arguments of the same call are applied after the preset and win. Setting a single key changes only that key, so styles can be mixed. Letter case does not matter. |
grid | NULL | Character or NULL. "none" (no grid lines, the default of both styles) or "y" (horizontal major grid lines only). Heat maps never show grid lines. Letter case does not matter. |
title_face | NULL | Character or NULL. Face of plot titles, "bold" ("default"), "plain" ("classic"), "italic" or "bold.italic". Letter case does not matter. |
title_color | NULL | Character or NULL. Color of plot titles, "black" in both styles. "quantity" gives the title the theme color of the quantity that the plot shows (stock size, fishing mortality, recruitment or catch), darkened where needed for a contrast ratio of at least 4.5 to 1 with white (lines and bars keep the exact color), and black for other plots; any other color name or code is used as given. Letter case does not matter. |
stock_color | NULL | Character or NULL. Line or bar color of stock size (plot_SSB(), plot_biomass(), plot_abundance()). The default style uses "#047c6c"; NULL ("classic") uses line_color. Interval bands take the color of their line unless se_color is set to a color other than the band color of the palette. Pass NULL explicitly to clear a color. |
F_color | NULL | Character or NULL. Color of fishing mortality (plot_fishing_mortality(), the F deviations of plot_deviance()). The default style uses "#ed5f26"; NULL ("classic") uses line_color. |
recruitment_color | NULL | Character or NULL. Color of recruitment (plot_recruitment(), the recruitment deviations of plot_deviance()). The default style uses "#28b3e8"; NULL ("classic") uses line_color. |
catch_color | NULL | Character or NULL. Color of catch (plot_catch(), the fitted series of plot_relative_catch()). The default style uses "#002b5f"; NULL ("classic") uses line_color. |
bars | NULL | Logical or NULL. Draw total recruitment and total catch as bars (TRUE, "default") or lines (FALSE, "classic"). The geom argument of plot_recruitment() and plot_catch() chooses per call. |
y_zero | NULL | Logical or NULL. Start the y axis of stock size, recruitment, catch and fishing mortality plots, and of plot_compare_ts() and plot_compare_F_ts(), at zero with no gap below it (TRUE, "default"), or let it follow the data (FALSE, "classic"). |
strip | NULL | Character or NULL. Style of the panel labels, "plain" (bold, left aligned black text without a box, "default") or "box" (the strips of the base theme, "classic"). Letter case does not matter. |
legend_position | NULL | Character or NULL. Position of the legend of plots that have one, "bottom" ("default"), "top", "left", "right" or "none". NULL ("classic") keeps the position of each plot. Comparison plots use compare_legend_pos. Letter case does not matter. |
axis_color | NULL | Character or NULL. With the default base theme ("theme_bw"), the color of the panel border, axis text and ticks, on a white panel ("black" under "default"). NULL ("classic") keeps the base theme. |
... | … | The former argument name compare_linewidth, accepted with a warning. |
interval | NULL | Character. Default 95% interval of positive quantities (abundance, biomass, spawning stock biomass, recruitment, catch and fishing mortality), "lognormal" (default) or "wald". See |
show_title | NULL | Logical or NULL. Draw the default titles of the plots (TRUE, the default of both styles). FALSE removes them from every plot; a title given as a character string in a plot call is still drawn, and the titles of the panels of multi-panel figures stay because they name the panels. |
x_angle | NULL | Numeric or NULL. Angle in degrees of the tick labels of time axes in multi-panel figures. NULL (default) draws them horizontal when they fit the width of the panels with a clear gap and at 45 degrees when they do not; 0 keeps them horizontal and thins them instead; another number uses that angle. Single-panel figures keep horizontal labels unless a number other than 0 is set. An |
Value
Invisibly, the settings before the call, the full list that acl_theme() returns; do.call(acl_theme_set, old) restores them. The call updates the global settings.
Details
The default style is style = "default", and style = "classic" gives in one call the npg palette, lines for every series, centered plain titles, boxed facet labels and y axes that follow the data. The default texts in the figures, the number of facet columns and the rules for tick labels are the same under both styles. A style sets palette, grid, title_face, title_hjust, title_color, the four quantity colors, bars, y_zero, line_size and compare_line_size (1 and 0.9 under the default style, 1.5 and 1.2 under the classic style), se_alpha, compare_se_alpha, strip, legend_position and axis_color; each of them can also be set alone, for example acl_theme_set(grid = "y") for horizontal grid lines, which neither style draws. Choose the default palette, a ggsci palette or explicit role colors; a palette leaves the four quantity colors unchanged, and setting one of them to NULL gives that quantity the line color of the palette. Omitted arguments leave existing settings unchanged. Explicit x_breaks = NULL restores automatic breaks and ylab = list(survey = NULL) clears a survey-label override. Snapshots from acl_theme() keep these settings that can be NULL, so do.call(acl_theme_set, old) restores them. Changes apply to plots drawn afterwards, not to plot objects already created.
Titles are black, bold and left aligned under the default style; title_color = "quantity" gives the stock size, fishing mortality, recruitment and catch plots a title in the color of their quantity. show_title = FALSE removes the default titles of all plots and keeps titles given in a plot call; a key of titles set to "" or NA removes one title. x_angle sets the angle of the year labels of multi-panel figures. NULL slants them by 45 degrees only when they would touch, and 0 keeps them horizontal and thins them. compare_facet_ncol = NULL, the default, chooses the columns of comparison plots from the number of panels.
Point sizes inherit the global point_size (default 2.5) unless compare_point_size sets another size for the comparison plots. A point_size given in a plot call takes priority, and in plot_compare_CatL() its argument obs_size takes priority over the theme. Use acl_theme_set(compare_point_size = NULL) to restore global inheritance.
interval sets the default 95% interval of positive quantities (abundance, biomass, spawning stock biomass, recruitment, catch and fishing mortality), "lognormal" (default) or "wald". A global x_breaks is used by a plot only when at least one break lies within the range of its x axis, so calendar-year breaks do not blank age or length axes. Error bars are drawn opaque unless a plot call supplies se_alpha. An unsupported setting, such as an unknown base theme, is an error.
Additional details from R help
Calling acl_theme_set() without arguments changes nothing, and acl_theme_reset() restores the defaults.
Styles
"default" draws stock size, fishing mortality, recruitment and
catch each in its own color, draws total recruitment and total catch as
bars, starts the y axis of these plots at zero, puts the legend below
the plot, and uses bold left-aligned titles, plain facet labels and a
black panel border. "classic" uses the npg palette, centered
plain titles, lines for every series, y axes that follow the data and
grey boxed facet labels. Neither draws grid lines, and the default
texts, the number of facet columns and the tick labels are the same
under both. A style sets palette, grid, title_face, title_hjust,
title_color, the four quantity colors, bars, y_zero, se_alpha,
compare_se_alpha, strip, legend_position, axis_color, line_size,
compare_line_size and the palette-derived colors, and setting a single
key changes only that key, so styles can be mixed.
Colors and export
gives the values of both styles, the six palettes and the rule for the
year labels of time axes.
Examples
Run the setup before the example. Fitting examples require an R-compatible C++ toolchain; simulation and export examples may write files.
Example setup
library(ALSCL)
# Use objects defined above
acl_theme_set(base_theme = "bw", line_color = "navy")

for (p in c("default", "npg", "aaas", "nejm", "lancet", "jama")) scales::show_col(acl_palette(palette = p))