## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set(collapse = FALSE, comment = "", fig.width = 7, fig.height = 4.5, dpi = 96, dev.args = list(bg = "transparent")) # Console colour carries no meaning on a rendered page. pkgdown turns it on for # its own build, and the escape sequences then reach the reader as literal text, # so colour is switched off here for a plain vignette render and a site build # alike. The fixed width keeps printed output inside the documentation column. options(cli.num_colors = 1, cli.hyperlink = FALSE, crayon.enabled = FALSE, width = 80) # Figures on the package website sit on a warm off-white page in light mode and # are inverted by pkgdown in dark mode, so an opaque background would read as a # pale slab one way and a black plate the other. Two things paint one. The # device canvas is made transparent by `dev.args` above, and theme_depictr() # then inherits theme_minimal()'s white plot.background, which is drawn over # that canvas, so it is cleared as each figure is printed. This is deliberately # a vignette-level choice: theme_depictr() keeps its opaque background, which # is what a figure saved for a paper wants. transparent_bg <- ggplot2::theme( plot.background = ggplot2::element_rect(fill = NA, colour = NA), panel.background = ggplot2::element_rect(fill = NA, colour = NA) ) knit_print.ggplot <- function(x, ...) knitr::normal_print(x + transparent_bg) knit_print.patchwork <- function(x, ...) knitr::normal_print(x & transparent_bg) library(depictr) ## ----------------------------------------------------------------------------- explore_distribution(lexical_decision, RT, group = condition, type = "density", legend_inside = TRUE) ## ----------------------------------------------------------------------------- explore_distribution(wellbeing_survey, life_satisfaction, group = region, type = "both", facet = TRUE) ## ----------------------------------------------------------------------------- ecdf_plot(lexical_decision, RT, group = condition, reference_quantiles = c(0.25, 0.5, 0.75), legend_inside = TRUE) ## ----------------------------------------------------------------------------- explore_categorical(wellbeing_survey, education, group = region, proportion = TRUE, position = "dodge") ## ----------------------------------------------------------------------------- explore_bivariate(lexical_decision, condition, RT) ## ----------------------------------------------------------------------------- scatter_trend(crop_yield, fertiliser, yield, group = treatment) ## ----fig.height = 6----------------------------------------------------------- explore_pairs(crop_yield, cols = c("rainfall", "fertiliser", "soil_ph", "yield")) ## ----fig.height = 5----------------------------------------------------------- correlation_heatmap(wellbeing_survey) ## ----fig.height = 5----------------------------------------------------------- correlation_heatmap(wellbeing_survey, reorder = TRUE) ## ----------------------------------------------------------------------------- raincloud_plot(lexical_decision, RT, group = condition) ## ----------------------------------------------------------------------------- group_comparison_plot(lexical_decision, RT, condition) ## ----fig.height = 4----------------------------------------------------------- ridgeline_plot(wellbeing_survey, life_satisfaction, region) ## ----fig.height = 5----------------------------------------------------------- set.seed(1) estimation_plot(lexical_decision, RT, condition, title = "RT difference: unrelated vs. related priming") ## ----fig.height = 5----------------------------------------------------------- set.seed(1) group_comparison_plot(crop_yield, yield, treatment, differences = TRUE, title = "Yield difference: enhanced vs. standard") ## ----------------------------------------------------------------------------- wb <- wellbeing_survey wb$age_group <- ifelse(wb$age < median(wb$age), "younger", "older") dumbbell_plot(wb, region, life_satisfaction, age_group, legend_inside = TRUE) ## ----------------------------------------------------------------------------- outlier_plot(crop_yield, yield) ## ----fig.height = 5----------------------------------------------------------- missingness_map(wellbeing_survey, legend_inside = TRUE) ## ----------------------------------------------------------------------------- tab <- summary_table( wellbeing_survey, vars = c("life_satisfaction", "income", "stress", "education"), group = "region" ) knitr::kable(tab) ## ----------------------------------------------------------------------------- library(ggplot2) scatter_trend(crop_yield, fertiliser, yield, group = treatment) + labs(title = "Yield rises with fertiliser", subtitle = "More steeply under the enhanced treatment") + theme(legend.position = "bottom") ## ----------------------------------------------------------------------------- ecdf_plot(lexical_decision, RT, group = condition) + labs(colour = NULL) + guides(colour = guide_legend(reverse = TRUE)) ## ----------------------------------------------------------------------------- explore_categorical(wellbeing_survey, education, group = region, proportion = TRUE, position = "dodge") + theme(legend.position = "inside", legend.position.inside = c(0.98, 0.98), legend.justification = c(1, 1), legend.title = element_blank())