Default ggstylekit::style_spec() for plot_forest() /
plot_build_forest(). Series names are the plot roles: point (the
estimate), errorbar (the CI line range), ref_point (the estimate of a
reference row: a reference copy in a covariate panel or the reference
panel; an open circle by default), ref_line (the
vertical reference line drawn at ref), and ref_band (the equivalence
band drawn at ref_band; a geom_rect annotation whose fill
and alpha come from the fill / alphas maps).
Arguments
- ...
Fields passed to
ggstylekit::style_spec(), overriding the preset defaults; call the preset with no arguments to view them. Per-series maps merge entry-wise onto the defaults (e.g.shapes = c(point = 18)leaves the other roles unchanged;colors = c(FOOD = "red")adds a covariate color while keeping the role colors); all other fields replace their default wholesale. A palettefunction(n)incolorscolours every covariate (called with the number of covariates); it replaces the role entries, which then fall back to the ggplot2 defaults.
Details
Per-covariate coloring is opt-in through the same colors map: add entries
keyed by covariate name (the values of the cov_name_var column, e.g.
colors = c(FOOD = "darkgreen", WTBL = "darkblue")). When at least one
covariate present in the plotted data has an entry, the builder maps point
and error bar color to the covariate (facet) and suppresses the legend,
since the facet strips already label each covariate. Covariates without an
entry take colours from the house palette, as for col_var in
plot_dvtime(). The point, errorbar, and ref_point role colours are
then replaced by the covariate colour; the reference panel keeps
the ref_point colour unless colors names it. ref_line is unaffected.
The builder draws the covariate row facet itself (facet_grid(rows = cov_name, switch = "y")), so the facet* fields are ignored. It labels
the x-axis with the rendered metric unless the xlabel field is supplied,
and draws no title unless the title field is supplied.
The house theme uses the forest panel variant of theme_bw(): a faint
vertical ruler, no horizontal gridlines, covariate panels stacked without
spacing into one frame, bold top-left covariate strips placed outside the y-axis,
and the estimate column as right-hand axis text under a bold header drawn
as the right-aligned subtitle on the top edge of the panels (style them
through theme = with axis.text.y.right and plot.subtitle). Set
logx = TRUE for a log x-axis.
Intervals are drawn as uncapped lines. Set the errorbar_width field to
draw capped error bars instead; it is the cap height in row heights (e.g.
style_forest(errorbar_width = 0.3), where 1 spans a full row). The
preset leaves it unset, which the builder back-fills to 0 (no cap).
See also
style_forest_pmforest(), style_forest_coveffectsplot(), style_forest_pmxforest(),
and style_forest_pumas() for the looks of the pmforest, coveffectsplot,
and PMXForest packages and of Pumas.
Other forest plot:
df_forest(),
df_forest_preprocess(),
is_forest_stats(),
plot_build_forest(),
plot_forest(),
style_forest_coveffectsplot(),
style_forest_pmforest(),
style_forest_pmxforest(),
style_forest_pumas()
Examples
style_forest()
#> <ggstylekit_style_spec>
#> colors black , black , black , grey30
#> fill white , grey80
#> linetypes solid , dashed
#> alphas 1.0, 1.0, 1.0, 1.0, 0.3
#> shapes 16, 21
#> sizes 2.2, 2.2
#> linewidths 0.6, 0.6
#> point_color NULL
#> point_alpha NULL
#> point_size NULL
#> point_shape NULL
#> line_color NULL
#> line_alpha NULL
#> line_linetype NULL
#> line_linewidth NULL
#> line_fill NULL
#> errorbar_color NULL
#> errorbar_alpha NULL
#> errorbar_linetype NULL
#> errorbar_linewidth NULL
#> errorbar_width NULL
#> errorbar_fill NULL
#> bar_fill NULL
#> bar_color NULL
#> bar_alpha NULL
#> bar_linewidth NULL
#> area_fill NULL
#> area_color NULL
#> area_alpha NULL
#> area_linewidth NULL
#> box_fill NULL
#> box_color NULL
#> box_alpha NULL
#> box_linewidth NULL
#> title NULL
#> xlabel NULL
#> ylabel NULL
#> caption NULL
#> xlims NULL
#> ylims NULL
#> logx NULL
#> logy NULL
#> xbreaks NULL
#> ybreaks NULL
#> xminor_breaks NULL
#> yminor_breaks NULL
#> xtick_labels NULL
#> ytick_labels NULL
#> xorder NULL
#> yorder NULL
#> equal_axis NULL
#> legends NULL
#> legend.position none
#> legend.title.position NULL
#> legend_nrow NULL
#> legend_ncol NULL
#> legend.title.hjust NULL
#> caption_hjust NULL
#> fill_alpha NULL
#> facet NULL
#> facet_scales NULL
#> facet_nrow NULL
#> facet_ncol NULL
#> theme <ggplot2 theme>
style_forest(shapes = c(point = 18), sizes = c(point = 3))
#> <ggstylekit_style_spec>
#> colors black , black , black , grey30
#> fill white , grey80
#> linetypes solid , dashed
#> alphas 1.0, 1.0, 1.0, 1.0, 0.3
#> shapes 18, 21
#> sizes 3.0, 2.2
#> linewidths 0.6, 0.6
#> point_color NULL
#> point_alpha NULL
#> point_size NULL
#> point_shape NULL
#> line_color NULL
#> line_alpha NULL
#> line_linetype NULL
#> line_linewidth NULL
#> line_fill NULL
#> errorbar_color NULL
#> errorbar_alpha NULL
#> errorbar_linetype NULL
#> errorbar_linewidth NULL
#> errorbar_width NULL
#> errorbar_fill NULL
#> bar_fill NULL
#> bar_color NULL
#> bar_alpha NULL
#> bar_linewidth NULL
#> area_fill NULL
#> area_color NULL
#> area_alpha NULL
#> area_linewidth NULL
#> box_fill NULL
#> box_color NULL
#> box_alpha NULL
#> box_linewidth NULL
#> title NULL
#> xlabel NULL
#> ylabel NULL
#> caption NULL
#> xlims NULL
#> ylims NULL
#> logx NULL
#> logy NULL
#> xbreaks NULL
#> ybreaks NULL
#> xminor_breaks NULL
#> yminor_breaks NULL
#> xtick_labels NULL
#> ytick_labels NULL
#> xorder NULL
#> yorder NULL
#> equal_axis NULL
#> legends NULL
#> legend.position none
#> legend.title.position NULL
#> legend_nrow NULL
#> legend_ncol NULL
#> legend.title.hjust NULL
#> caption_hjust NULL
#> fill_alpha NULL
#> facet NULL
#> facet_scales NULL
#> facet_nrow NULL
#> facet_ncol NULL
#> theme <ggplot2 theme>
style_forest(fill = c(ref_band = "skyblue"), alphas = c(ref_band = 0.2))
#> <ggstylekit_style_spec>
#> colors black , black , black , grey30
#> fill white , skyblue
#> linetypes solid , dashed
#> alphas 1.0, 1.0, 1.0, 1.0, 0.2
#> shapes 16, 21
#> sizes 2.2, 2.2
#> linewidths 0.6, 0.6
#> point_color NULL
#> point_alpha NULL
#> point_size NULL
#> point_shape NULL
#> line_color NULL
#> line_alpha NULL
#> line_linetype NULL
#> line_linewidth NULL
#> line_fill NULL
#> errorbar_color NULL
#> errorbar_alpha NULL
#> errorbar_linetype NULL
#> errorbar_linewidth NULL
#> errorbar_width NULL
#> errorbar_fill NULL
#> bar_fill NULL
#> bar_color NULL
#> bar_alpha NULL
#> bar_linewidth NULL
#> area_fill NULL
#> area_color NULL
#> area_alpha NULL
#> area_linewidth NULL
#> box_fill NULL
#> box_color NULL
#> box_alpha NULL
#> box_linewidth NULL
#> title NULL
#> xlabel NULL
#> ylabel NULL
#> caption NULL
#> xlims NULL
#> ylims NULL
#> logx NULL
#> logy NULL
#> xbreaks NULL
#> ybreaks NULL
#> xminor_breaks NULL
#> yminor_breaks NULL
#> xtick_labels NULL
#> ytick_labels NULL
#> xorder NULL
#> yorder NULL
#> equal_axis NULL
#> legends NULL
#> legend.position none
#> legend.title.position NULL
#> legend_nrow NULL
#> legend_ncol NULL
#> legend.title.hjust NULL
#> caption_hjust NULL
#> fill_alpha NULL
#> facet NULL
#> facet_scales NULL
#> facet_nrow NULL
#> facet_ncol NULL
#> theme <ggplot2 theme>
style_forest(shapes = c(ref_point = 16), colors = c(ref_point = "grey50"))
#> <ggstylekit_style_spec>
#> colors black , black , grey50, grey30
#> fill white , grey80
#> linetypes solid , dashed
#> alphas 1.0, 1.0, 1.0, 1.0, 0.3
#> shapes 16, 16
#> sizes 2.2, 2.2
#> linewidths 0.6, 0.6
#> point_color NULL
#> point_alpha NULL
#> point_size NULL
#> point_shape NULL
#> line_color NULL
#> line_alpha NULL
#> line_linetype NULL
#> line_linewidth NULL
#> line_fill NULL
#> errorbar_color NULL
#> errorbar_alpha NULL
#> errorbar_linetype NULL
#> errorbar_linewidth NULL
#> errorbar_width NULL
#> errorbar_fill NULL
#> bar_fill NULL
#> bar_color NULL
#> bar_alpha NULL
#> bar_linewidth NULL
#> area_fill NULL
#> area_color NULL
#> area_alpha NULL
#> area_linewidth NULL
#> box_fill NULL
#> box_color NULL
#> box_alpha NULL
#> box_linewidth NULL
#> title NULL
#> xlabel NULL
#> ylabel NULL
#> caption NULL
#> xlims NULL
#> ylims NULL
#> logx NULL
#> logy NULL
#> xbreaks NULL
#> ybreaks NULL
#> xminor_breaks NULL
#> yminor_breaks NULL
#> xtick_labels NULL
#> ytick_labels NULL
#> xorder NULL
#> yorder NULL
#> equal_axis NULL
#> legends NULL
#> legend.position none
#> legend.title.position NULL
#> legend_nrow NULL
#> legend_ncol NULL
#> legend.title.hjust NULL
#> caption_hjust NULL
#> fill_alpha NULL
#> facet NULL
#> facet_scales NULL
#> facet_nrow NULL
#> facet_ncol NULL
#> theme <ggplot2 theme>
style_forest(colors = c(FOOD = "firebrick", WTBL = "steelblue", Reference = "grey20"))
#> <ggstylekit_style_spec>
#> colors black , black , black , grey30 , firebrick, steelblue, grey20
#> fill white , grey80
#> linetypes solid , dashed
#> alphas 1.0, 1.0, 1.0, 1.0, 0.3
#> shapes 16, 21
#> sizes 2.2, 2.2
#> linewidths 0.6, 0.6
#> point_color NULL
#> point_alpha NULL
#> point_size NULL
#> point_shape NULL
#> line_color NULL
#> line_alpha NULL
#> line_linetype NULL
#> line_linewidth NULL
#> line_fill NULL
#> errorbar_color NULL
#> errorbar_alpha NULL
#> errorbar_linetype NULL
#> errorbar_linewidth NULL
#> errorbar_width NULL
#> errorbar_fill NULL
#> bar_fill NULL
#> bar_color NULL
#> bar_alpha NULL
#> bar_linewidth NULL
#> area_fill NULL
#> area_color NULL
#> area_alpha NULL
#> area_linewidth NULL
#> box_fill NULL
#> box_color NULL
#> box_alpha NULL
#> box_linewidth NULL
#> title NULL
#> xlabel NULL
#> ylabel NULL
#> caption NULL
#> xlims NULL
#> ylims NULL
#> logx NULL
#> logy NULL
#> xbreaks NULL
#> ybreaks NULL
#> xminor_breaks NULL
#> yminor_breaks NULL
#> xtick_labels NULL
#> ytick_labels NULL
#> xorder NULL
#> yorder NULL
#> equal_axis NULL
#> legends NULL
#> legend.position none
#> legend.title.position NULL
#> legend_nrow NULL
#> legend_ncol NULL
#> legend.title.hjust NULL
#> caption_hjust NULL
#> fill_alpha NULL
#> facet NULL
#> facet_scales NULL
#> facet_nrow NULL
#> facet_ncol NULL
#> theme <ggplot2 theme>
style_forest(logx = TRUE)
#> <ggstylekit_style_spec>
#> colors black , black , black , grey30
#> fill white , grey80
#> linetypes solid , dashed
#> alphas 1.0, 1.0, 1.0, 1.0, 0.3
#> shapes 16, 21
#> sizes 2.2, 2.2
#> linewidths 0.6, 0.6
#> point_color NULL
#> point_alpha NULL
#> point_size NULL
#> point_shape NULL
#> line_color NULL
#> line_alpha NULL
#> line_linetype NULL
#> line_linewidth NULL
#> line_fill NULL
#> errorbar_color NULL
#> errorbar_alpha NULL
#> errorbar_linetype NULL
#> errorbar_linewidth NULL
#> errorbar_width NULL
#> errorbar_fill NULL
#> bar_fill NULL
#> bar_color NULL
#> bar_alpha NULL
#> bar_linewidth NULL
#> area_fill NULL
#> area_color NULL
#> area_alpha NULL
#> area_linewidth NULL
#> box_fill NULL
#> box_color NULL
#> box_alpha NULL
#> box_linewidth NULL
#> title NULL
#> xlabel NULL
#> ylabel NULL
#> caption NULL
#> xlims NULL
#> ylims NULL
#> logx TRUE
#> logy NULL
#> xbreaks NULL
#> ybreaks NULL
#> xminor_breaks NULL
#> yminor_breaks NULL
#> xtick_labels NULL
#> ytick_labels NULL
#> xorder NULL
#> yorder NULL
#> equal_axis NULL
#> legends NULL
#> legend.position none
#> legend.title.position NULL
#> legend_nrow NULL
#> legend_ncol NULL
#> legend.title.hjust NULL
#> caption_hjust NULL
#> fill_alpha NULL
#> facet NULL
#> facet_scales NULL
#> facet_nrow NULL
#> facet_ncol NULL
#> theme <ggplot2 theme>
style_forest(errorbar_width = 0.3)
#> <ggstylekit_style_spec>
#> colors black , black , black , grey30
#> fill white , grey80
#> linetypes solid , dashed
#> alphas 1.0, 1.0, 1.0, 1.0, 0.3
#> shapes 16, 21
#> sizes 2.2, 2.2
#> linewidths 0.6, 0.6
#> point_color NULL
#> point_alpha NULL
#> point_size NULL
#> point_shape NULL
#> line_color NULL
#> line_alpha NULL
#> line_linetype NULL
#> line_linewidth NULL
#> line_fill NULL
#> errorbar_color NULL
#> errorbar_alpha NULL
#> errorbar_linetype NULL
#> errorbar_linewidth NULL
#> errorbar_width 0.3
#> errorbar_fill NULL
#> bar_fill NULL
#> bar_color NULL
#> bar_alpha NULL
#> bar_linewidth NULL
#> area_fill NULL
#> area_color NULL
#> area_alpha NULL
#> area_linewidth NULL
#> box_fill NULL
#> box_color NULL
#> box_alpha NULL
#> box_linewidth NULL
#> title NULL
#> xlabel NULL
#> ylabel NULL
#> caption NULL
#> xlims NULL
#> ylims NULL
#> logx NULL
#> logy NULL
#> xbreaks NULL
#> ybreaks NULL
#> xminor_breaks NULL
#> yminor_breaks NULL
#> xtick_labels NULL
#> ytick_labels NULL
#> xorder NULL
#> yorder NULL
#> equal_axis NULL
#> legends NULL
#> legend.position none
#> legend.title.position NULL
#> legend_nrow NULL
#> legend_ncol NULL
#> legend.title.hjust NULL
#> caption_hjust NULL
#> fill_alpha NULL
#> facet NULL
#> facet_scales NULL
#> facet_nrow NULL
#> facet_ncol NULL
#> theme <ggplot2 theme>
