Update documentation

This commit is contained in:
gnoblet 2022-11-20 19:02:03 -04:00
parent 0198ad53c3
commit cb9a8bfcac
14 changed files with 243 additions and 220 deletions

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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, ...) {

View file

@ -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()`.
#'

85
man/bar_reach.Rd Normal file
View file

@ -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.
}

View file

@ -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
}

View file

@ -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
}

76
man/point_reach.Rd Normal file
View file

@ -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.
}

View file

@ -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

View file

@ -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

View file

@ -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.
}

View file

@ -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
}

View file

@ -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.
}

View file

@ -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.
}