From cb9a8bfcac535fcba0eeaa1e57295c61a6f3ea55 Mon Sep 17 00:00:00 2001 From: gnoblet Date: Sun, 20 Nov 2022 19:02:03 -0400 Subject: [PATCH] Update documentation --- R/bar.R | 6 +-- R/point.R | 6 +-- R/scale.R | 26 ++++++----- R/theme_reach.R | 5 ++- man/bar_reach.Rd | 85 ++++++++++++++++++++++++++++++++++++ man/hbar.Rd | 67 ---------------------------- man/hbar_percent.Rd | 67 ---------------------------- man/point_reach.Rd | 76 ++++++++++++++++++++++++++++++++ man/scale_color.Rd | 13 +++--- man/scale_fill.Rd | 15 ++++--- man/theme_reach.Rd | 46 +++++++++++++++++-- man/theme_reach_borders.Rd | 17 -------- man/theme_reach_flip_hist.Rd | 17 -------- man/theme_reach_hist.Rd | 17 -------- 14 files changed, 243 insertions(+), 220 deletions(-) create mode 100644 man/bar_reach.Rd delete mode 100644 man/hbar.Rd delete mode 100644 man/hbar_percent.Rd create mode 100644 man/point_reach.Rd delete mode 100644 man/theme_reach_borders.Rd delete mode 100644 man/theme_reach_flip_hist.Rd delete mode 100644 man/theme_reach_hist.Rd diff --git a/R/bar.R b/R/bar.R index 8614ffe..6f7e77e 100644 --- a/R/bar.R +++ b/R/bar.R @@ -20,7 +20,7 @@ #' @param text_size The size of all text other than the title, subtitle and caption. Defaults to 10. #' @param title_size The size of the title text. Defaults to 14. #' @param legend_position Position of the legend; Default to "right". Can take "right", "left", "top", "bottom" or "none". -#' @param legend_direction Direction of the legend. Default to "vertical". Can take "vertical" or "horizontal". +#' @param legend_rev Reverse the color in the guide? Default to TRUE. #' @param void Boolean to remove all elements from the plot. Default to FALSE. #' @param ... Other arguments to be passed to "ggblanket::gg_col" #' @@ -41,7 +41,7 @@ bar_reach <- function(df, x, y, group = NULL, percent = TRUE, palette = "main", if (percent) x_labels <- scales::percent else x_labels <- NULL - hbar <- df |> + pl <- df |> ggblanket::gg_col(x = {{ x }}, y = {{ y }}, col = {{ group }}, @@ -70,5 +70,5 @@ bar_reach <- function(df, x, y, group = NULL, percent = TRUE, palette = "main", ... ) - return(hbar) + return(pl) } diff --git a/R/point.R b/R/point.R index b2ed023..ed7c973 100644 --- a/R/point.R +++ b/R/point.R @@ -12,14 +12,12 @@ #' @param x_title The x scale title. Default to NULL. #' @param y_title The y scale title. Default to NULL. #' @param group_title The group legend title. Default to NULL. -#' @param position Should the chart be stacked? Default to "dodge". Can take "dodge" and "stack". #' @param title Plot title. Default to NULL. #' @param subtitle Plot subtitle. Default to NULL. #' @param caption Caption title string. Default to NULL. #' @param text_size The size of all text other than the title, subtitle and caption. Defaults to 10. #' @param title_size The size of the title text. Defaults to 14. #' @param legend_position Position of the legend; Default to "right". Can take "right", "left", "top", "bottom" or "none". -#' @param legend_direction Direction of the legend. Default to "vertical". Can take "vertical" or "horizontal". #' @param void Boolean to remove all elements from the plot. Default to FALSE. #' @param ... Other arguments to be passed to "ggblanket::gg_col" #' @@ -38,7 +36,7 @@ point_reach <- function(df, x, y, group = NULL, palette = "main", reverse = FALS ) ) - hbar <- df |> + pl <- df |> ggblanket::gg_point(x = {{ x }}, y = {{ y }}, col = {{ group }}, @@ -64,5 +62,5 @@ point_reach <- function(df, x, y, group = NULL, palette = "main", reverse = FALS ... ) - return(hbar) + return(pl) } diff --git a/R/scale.R b/R/scale.R index c3a4719..8dec956 100644 --- a/R/scale.R +++ b/R/scale.R @@ -1,11 +1,13 @@ #' Color scale constructor for REACH or AGORA colors #' -#' @param initiative Either "reach" or "agora -#' @param palette Palette name from `pal_reach()` or `pal_agora()` -#' @param discrete Boolean indicating whether color aesthetic is discrete or not -#' @param reverse Boolean indicating whether the palette should be reversed +#' @param initiative Either "reach" or "agora. +#' @param palette Palette name from `pal_reach()` or `pal_agora()`. +#' @param discrete Boolean indicating whether color aesthetic is discrete or not. +#' @param reverse Boolean indicating whether the palette should be reversed. +#' @param reverse_guide Boolean indicating whether the guide should be reversed. #' @param ... Additional arguments passed to discrete_scale() or -#' scale_color_gradient(), used respectively when discrete is TRUE or FALSE +#' scale_fill_gradient(), used respectively when discrete is TRUE or FALSE. +#' #' @return A color scale for ggplot #' #' @export @@ -59,13 +61,15 @@ scale_color <- function(initiative = "reach", palette = "main", discrete = TRUE #' Fill scale constructor for REACH or AGORA colors #' -#' @param initiative Either "reach" or "agora -#' @param palette Palette name from `pal_reach()` or `pal_agora()` -#' @param discrete Boolean indicating whether color aesthetic is discrete or not -#' @param reverse Boolean indicating whether the palette should be reversed +#' @param initiative Either "reach" or "agora. +#' @param palette Palette name from `pal_reach()` or `pal_agora()`. +#' @param discrete Boolean indicating whether color aesthetic is discrete or not. +#' @param reverse Boolean indicating whether the palette should be reversed. +#' @param reverse_guide Boolean indicating whether the guide should be reversed. #' @param ... Additional arguments passed to discrete_scale() or -#' scale_fill_gradient(), used respectively when discrete is TRUE or FALSE -#' @return A fill scale for ggplot +#' scale_fill_gradient(), used respectively when discrete is TRUE or FALSE. +#' +#' @return A fill scale for ggplot. #' #' @export scale_fill <- function(initiative = "reach", palette = "main", discrete = TRUE, reverse = FALSE, reverse_guide = TRUE, ...) { diff --git a/R/theme_reach.R b/R/theme_reach.R index f0980ec..755800c 100644 --- a/R/theme_reach.R +++ b/R/theme_reach.R @@ -1,8 +1,8 @@ #' @title ggplot2 theme with REACH color palettes #' #' @param palette Palette name from 'pal_reach()'. -#' @param discrete Boolean indicating whether color aesthetic is discrete or not -#' @param reverse Boolean indicating whether the palette should be reversed +#' @param discrete Boolean indicating whether color aesthetic is discrete or not. +#' @param reverse Boolean indicating whether the palette should be reversed. #' @param family The font family for all plot's texts. Default to "Leelawadee". #' @param text_size The size of all text other than the title, subtitle and caption. Defaults to 10. #' @param title_size The size of the title text_family. Defaults to 14. @@ -10,6 +10,7 @@ #' @param panel_background_pal The color for the panel background color. Default to white. #' @param legend_position Position of the legend; Default to "right". Can take "right", "left", "top", "bottom" or "none". #' @param legend_direction Direction of the legend. Default to "vertical". Can take "vertical" or "horizontal". +#' @param legend_reverse Reverse the color in the guide? Default to TRUE. #' @param void Boolean to remove all elements from the plot. Default to FALSE. #' @param ... Additional arguments passed to `ggblanket::gg_theme()`. #' diff --git a/man/bar_reach.Rd b/man/bar_reach.Rd new file mode 100644 index 0000000..884952c --- /dev/null +++ b/man/bar_reach.Rd @@ -0,0 +1,85 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/bar.R +\name{bar_reach} +\alias{bar_reach} +\title{Simple bar chart} +\usage{ +bar_reach( + df, + x, + y, + group = NULL, + percent = TRUE, + palette = "main", + reverse = FALSE, + family = "Leelawadee", + alpha = 1, + width = 0.5, + x_title = NULL, + y_title = NULL, + group_title = NULL, + position = "dodge", + title = NULL, + subtitle = NULL, + caption = NULL, + text_size = 10, + title_size = 14, + legend_position = "right", + legend_rev = TRUE, + void = FALSE, + ... +) +} +\arguments{ +\item{df}{A data frame.} + +\item{x}{A numeric column.} + +\item{y}{A character column or coercible as a character column.} + +\item{group}{Some grouping categorical column, e.g. administrative areas or population groups.} + +\item{percent}{TRUE or FALSE. Should the x-labels be displayed as percentages? Default to TRUE.} + +\item{palette}{Palette name from 'pal_reach()'.} + +\item{reverse}{Boolean indicating whether the palette should be reversed.} + +\item{family}{The font family for all plot's texts. Default to "Leelawadee".} + +\item{alpha}{Transparency.} + +\item{width}{Width.} + +\item{x_title}{The x scale title. Default to NULL.} + +\item{y_title}{The y scale title. Default to NULL.} + +\item{group_title}{The group legend title. Default to NULL.} + +\item{position}{Should the chart be stacked? Default to "dodge". Can take "dodge" and "stack".} + +\item{title}{Plot title. Default to NULL.} + +\item{subtitle}{Plot subtitle. Default to NULL.} + +\item{caption}{Caption title string. Default to NULL.} + +\item{text_size}{The size of all text other than the title, subtitle and caption. Defaults to 10.} + +\item{title_size}{The size of the title text. Defaults to 14.} + +\item{legend_position}{Position of the legend; Default to "right". Can take "right", "left", "top", "bottom" or "none".} + +\item{legend_rev}{Reverse the color in the guide? Default to TRUE.} + +\item{void}{Boolean to remove all elements from the plot. Default to FALSE.} + +\item{...}{Other arguments to be passed to "ggblanket::gg_col"} +} +\value{ +A bar chart +} +\description{ +`ggblanket` as internals for deciding whether the bar chart is horizontally readable. +} diff --git a/man/hbar.Rd b/man/hbar.Rd deleted file mode 100644 index 9afca9f..0000000 --- a/man/hbar.Rd +++ /dev/null @@ -1,67 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/hbar.R -\name{hbar} -\alias{hbar} -\title{Simple horizontal bar chart} -\usage{ -hbar( - .tbl, - x, - y, - group = NULL, - initiative = "reach", - palette = "primary", - width = 0.5, - x_title = "", - y_title = "", - group_title = NULL, - font_family = "Leelawadee", - position = "dodge", - reverse = FALSE, - title = "", - subtitle = "", - gg_theme = NULL, - ... -) -} -\arguments{ -\item{.tbl}{Some data} - -\item{x}{Some numeric column on the x scale} - -\item{y}{Some column on the y scale} - -\item{group}{Some grouping categorical column, e.g. administrative areas} - -\item{initiative}{Either "reach" or "agora" or "impact" for the color palette} - -\item{palette}{The color palette from the initiative} - -\item{width}{Width} - -\item{x_title}{The x scale title. Default to empty string} - -\item{y_title}{The y scale title. Default to empty string} - -\item{group_title}{The group legend title. Defaut to NULL} - -\item{font_family}{The font family. Default to "Leelawadee"} - -\item{position}{Should the chart be stacked? Default to dodge} - -\item{reverse}{Boolean indicating whether the color palette should be reversed} - -\item{title}{Plot title. Default to empty string} - -\item{subtitle}{Plot subtitle. Default to empty string} - -\item{gg_theme}{Some ggplot2 theme} - -\item{...}{Other arguments to be passed to "ggblanket::gg_col"} -} -\value{ -A horizontal bar chart -} -\description{ -Simple horizontal bar chart -} diff --git a/man/hbar_percent.Rd b/man/hbar_percent.Rd deleted file mode 100644 index 07daebd..0000000 --- a/man/hbar_percent.Rd +++ /dev/null @@ -1,67 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/hbar.R -\name{hbar_percent} -\alias{hbar_percent} -\title{Simple horizontal bar chart which scales x_labels to percentages} -\usage{ -hbar_percent( - .tbl, - x, - y, - group = NULL, - initiative = "reach", - palette = "primary", - width = 0.5, - x_title = "", - y_title = "", - group_title = NULL, - font_family = "Leelawadee", - position = "dodge", - reverse = FALSE, - title = "", - subtitle = "", - gg_theme = NULL, - ... -) -} -\arguments{ -\item{.tbl}{Some data} - -\item{x}{Some numeric column on the x scale} - -\item{y}{Some column on the y scale} - -\item{group}{Some grouping categorical column, e.g. administrative areas} - -\item{initiative}{Either "reach" or "agora" or "impact" for the color palette} - -\item{palette}{The color palette from the initiative} - -\item{width}{Width} - -\item{x_title}{The x scale title. Default to empty string} - -\item{y_title}{The y scale title. Default to empty string} - -\item{group_title}{The group legend title. Defaut to NULL} - -\item{font_family}{The font family. Default to "Leelawadee"} - -\item{position}{Should the chart be stacked? Default to dodge} - -\item{reverse}{Boolean indicating whether the color palette should be reversed} - -\item{title}{Plot title. Default to empty string} - -\item{subtitle}{Plot subtitle. Default to empty string} - -\item{gg_theme}{Some ggplot2 theme} - -\item{...}{Other arguments to be passed to "ggblanket::gg_col"} -} -\value{ -A horizontal bar chart -} -\description{ -Simple horizontal bar chart which scales x_labels to percentages -} diff --git a/man/point_reach.Rd b/man/point_reach.Rd new file mode 100644 index 0000000..8dbd591 --- /dev/null +++ b/man/point_reach.Rd @@ -0,0 +1,76 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/point.R +\name{point_reach} +\alias{point_reach} +\title{Simple point chart} +\usage{ +point_reach( + df, + x, + y, + group = NULL, + palette = "main", + reverse = FALSE, + family = "Leelawadee", + alpha = 1, + size = 1.5, + x_title = NULL, + y_title = NULL, + group_title = NULL, + title = NULL, + subtitle = NULL, + caption = NULL, + text_size = 10, + title_size = 14, + legend_position = "right", + void = FALSE, + ... +) +} +\arguments{ +\item{df}{A data frame.} + +\item{x}{A numeric column.} + +\item{y}{A character column or coercible as a character column.} + +\item{group}{Some grouping categorical column, e.g. administrative areas or population groups.} + +\item{palette}{Palette name from 'pal_reach()'.} + +\item{reverse}{Boolean indicating whether the palette should be reversed.} + +\item{family}{The font family for all plot's texts. Default to "Leelawadee".} + +\item{alpha}{Transparency.} + +\item{size}{Dot size. Default to 1.5.} + +\item{x_title}{The x scale title. Default to NULL.} + +\item{y_title}{The y scale title. Default to NULL.} + +\item{group_title}{The group legend title. Default to NULL.} + +\item{title}{Plot title. Default to NULL.} + +\item{subtitle}{Plot subtitle. Default to NULL.} + +\item{caption}{Caption title string. Default to NULL.} + +\item{text_size}{The size of all text other than the title, subtitle and caption. Defaults to 10.} + +\item{title_size}{The size of the title text. Defaults to 14.} + +\item{legend_position}{Position of the legend; Default to "right". Can take "right", "left", "top", "bottom" or "none".} + +\item{void}{Boolean to remove all elements from the plot. Default to FALSE.} + +\item{...}{Other arguments to be passed to "ggblanket::gg_col"} +} +\value{ +A bar chart +} +\description{ +`ggblanket` as internals for deciding whether the bar chart is horizontally readable. +} diff --git a/man/scale_color.Rd b/man/scale_color.Rd index 5139b2a..c05dcf9 100644 --- a/man/scale_color.Rd +++ b/man/scale_color.Rd @@ -9,20 +9,23 @@ scale_color( palette = "main", discrete = TRUE, reverse = FALSE, + reverse_guide = TRUE, ... ) } \arguments{ -\item{initiative}{Either "reach" or "agora} +\item{initiative}{Either "reach" or "agora.} -\item{palette}{Palette name from `pal_reach()` or `pal_agora()`} +\item{palette}{Palette name from `pal_reach()` or `pal_agora()`.} -\item{discrete}{Boolean indicating whether color aesthetic is discrete or not} +\item{discrete}{Boolean indicating whether color aesthetic is discrete or not.} -\item{reverse}{Boolean indicating whether the palette should be reversed} +\item{reverse}{Boolean indicating whether the palette should be reversed.} + +\item{reverse_guide}{Boolean indicating whether the guide should be reversed.} \item{...}{Additional arguments passed to discrete_scale() or -scale_color_gradient(), used respectively when discrete is TRUE or FALSE} +scale_fill_gradient(), used respectively when discrete is TRUE or FALSE.} } \value{ A color scale for ggplot diff --git a/man/scale_fill.Rd b/man/scale_fill.Rd index 5601e54..b07d1a8 100644 --- a/man/scale_fill.Rd +++ b/man/scale_fill.Rd @@ -9,23 +9,26 @@ scale_fill( palette = "main", discrete = TRUE, reverse = FALSE, + reverse_guide = TRUE, ... ) } \arguments{ -\item{initiative}{Either "reach" or "agora} +\item{initiative}{Either "reach" or "agora.} -\item{palette}{Palette name from `pal_reach()` or `pal_agora()`} +\item{palette}{Palette name from `pal_reach()` or `pal_agora()`.} -\item{discrete}{Boolean indicating whether color aesthetic is discrete or not} +\item{discrete}{Boolean indicating whether color aesthetic is discrete or not.} -\item{reverse}{Boolean indicating whether the palette should be reversed} +\item{reverse}{Boolean indicating whether the palette should be reversed.} + +\item{reverse_guide}{Boolean indicating whether the guide should be reversed.} \item{...}{Additional arguments passed to discrete_scale() or -scale_fill_gradient(), used respectively when discrete is TRUE or FALSE} +scale_fill_gradient(), used respectively when discrete is TRUE or FALSE.} } \value{ -A fill scale for ggplot +A fill scale for ggplot. } \description{ Fill scale constructor for REACH or AGORA colors diff --git a/man/theme_reach.Rd b/man/theme_reach.Rd index 7c760db..aa3c2af 100644 --- a/man/theme_reach.Rd +++ b/man/theme_reach.Rd @@ -2,16 +2,54 @@ % Please edit documentation in R/theme_reach.R \name{theme_reach} \alias{theme_reach} -\title{Base REACH ggplot2 theme} +\title{ggplot2 theme with REACH color palettes} \usage{ -theme_reach(family = "Leelawadee") +theme_reach( + palette = "main", + discrete = TRUE, + reverse = FALSE, + family = "Leelawadee", + text_size = 10, + title_size = 14, + plot_background_pal = "#FFFFFF", + panel_background_pal = "#FFFFFF", + void = FALSE, + legend_position = "right", + legend_direction = "vertical", + legend_reverse = TRUE, + ... +) } \arguments{ -\item{family}{The font family. Default to "Leelawadee"} +\item{palette}{Palette name from 'pal_reach()'.} + +\item{discrete}{Boolean indicating whether color aesthetic is discrete or not.} + +\item{reverse}{Boolean indicating whether the palette should be reversed.} + +\item{family}{The font family for all plot's texts. Default to "Leelawadee".} + +\item{text_size}{The size of all text other than the title, subtitle and caption. Defaults to 10.} + +\item{title_size}{The size of the title text_family. Defaults to 14.} + +\item{plot_background_pal}{The color for the plot background color. Default to white.} + +\item{panel_background_pal}{The color for the panel background color. Default to white.} + +\item{void}{Boolean to remove all elements from the plot. Default to FALSE.} + +\item{legend_position}{Position of the legend; Default to "right". Can take "right", "left", "top", "bottom" or "none".} + +\item{legend_direction}{Direction of the legend. Default to "vertical". Can take "vertical" or "horizontal".} + +\item{legend_reverse}{Reverse the color in the guide? Default to TRUE.} + +\item{...}{Additional arguments passed to `ggblanket::gg_theme()`.} } \value{ The base REACH theme } \description{ -Give some reach colors and fonts to a ggplot. Based on theme_bw() +Give some reach colors and fonts to a ggplot. } diff --git a/man/theme_reach_borders.Rd b/man/theme_reach_borders.Rd deleted file mode 100644 index c6cc1b6..0000000 --- a/man/theme_reach_borders.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/theme_reach.R -\name{theme_reach_borders} -\alias{theme_reach_borders} -\title{Some REACH theme for ggplot} -\usage{ -theme_reach_borders(family = "Leelawadee") -} -\arguments{ -\item{family}{The font family. Default to "Leelawadee"} -} -\value{ -A theme to be added to the "+" ggplot grammar -} -\description{ -Some REACH theme for ggplot -} diff --git a/man/theme_reach_flip_hist.Rd b/man/theme_reach_flip_hist.Rd deleted file mode 100644 index 10f1b7b..0000000 --- a/man/theme_reach_flip_hist.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/theme_reach.R -\name{theme_reach_flip_hist} -\alias{theme_reach_flip_hist} -\title{Some reach more minimal theme for a ggplot flipped histogram} -\usage{ -theme_reach_flip_hist(family = "Leelawadee") -} -\arguments{ -\item{family}{The font family. Default to "Leelawadee"} -} -\value{ -A theme to be added to the "+" ggplot grammar -} -\description{ -Give some REACH colors and fonts to a ggplot. Based on theme_bw(). To be used for horizontal bar charts. -} diff --git a/man/theme_reach_hist.Rd b/man/theme_reach_hist.Rd deleted file mode 100644 index bf88010..0000000 --- a/man/theme_reach_hist.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/theme_reach.R -\name{theme_reach_hist} -\alias{theme_reach_hist} -\title{Some reach more minimal theme for a ggplot histogram} -\usage{ -theme_reach_hist(family = "Leelawadee") -} -\arguments{ -\item{family}{The font family. Default to "Leelawadee"} -} -\value{ -A theme to be added to the "+" ggplot grammar -} -\description{ -Give some REACH colors and fonts to a ggplot. Based on theme_bw(). To be used for vertical bar charts. -}