geom_tree_tot_by_split: Shortcut functions for commonly used plots in RP style

View source: R/plots.R

geom_tree_tot_by_splitR Documentation

Shortcut functions for commonly used plots in RP style

Description

geom_tree_tot_by_split creates a 'treemap' chart of the total of one outcome, split by another outcome.

Usage

geom_tree_tot_by_split(
  df,
  outcome,
  splitvar,
  title = "",
  opts = list(treemapify::geom_treemap(alpha = 0.7),
    treemapify::geom_treemap_text(fontface = "italic", colour = "white", place =
    "centre", grow = TRUE, min.size = 1), theme(legend.position = "none", plot.title =
    element_text(hjust = 0.5)))
)

Arguments

opts

can be substituted with a (predefined or in-function) list of style parameters

Details

in future we could try to make this more general, allowing other types of summary

Examples

geom_treemap_opts_1 <- list(treemapify::geom_treemap(alpha = 0.5),
 treemapify::geom_treemap_text(fontface = "italic", colour = "blue", place = "centre",
                   grow = TRUE, min.size = 3 ),
 theme(legend.position = c(0.6, 0.2),
      plot.title = element_text(hjust = 0.5))
     )

 midwest %>% geom_tree_tot_by_split(popamerindian, state, title = "Shares of midwestern 'American Indian residents' by state", opts= geom_treemap_opts_1)

rethinkpriorities/rp-r-package documentation built on Jan. 7, 2023, 10:11 p.m.