diff --git a/.gitignore b/.gitignore index ae73e6d..ecb1ef1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .Rdata .httr-oauth .DS_Store +R/test.R diff --git a/DESCRIPTION b/DESCRIPTION index 083bbdd..20aabba 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: visualizeR Type: Package Title: What a color! What a viz! -Version: 0.3.9000 +Version: 0.4.9000 Authors@R: c( person( 'Noblet', 'Guillaume', @@ -17,13 +17,12 @@ Depends: R (>= 4.1.0) License: GPL (>= 3) Encoding: UTF-8 LazyData: true -RoxygenNote: 7.2.1 +RoxygenNote: 7.2.3 Imports: ggplot2, rlang, grDevices, glue, - scales, - ggblanket (== 1.6.1) + scales Suggests: knitr, sf, tmap VignetteBuilder: knitr diff --git a/NEWS.md b/NEWS.md index fa45d9e..eb52999 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,18 @@ +# visualizeR 0.4.9000 + +* Breaking changes: remove dependency to `ggblanket`. +* Full rewrite of `theme_reach()`. +* `bar_reach` is now `bar()` and theming is passed through argument `theme` for which default is `theme_reach()`. +* `point_reach` is now `point()` and theming is passed through argument `theme` for which default is `theme_reach()`. + +--- + # visualizeR 0.3.9000 * Breaking changes: update to `ggblanket` v1.6.1. * Add plotting functions for indicator maps. +--- # visualizeR 0.2.9000 diff --git a/R/bar.R b/R/bar.R index 094b97a..24ddae8 100644 --- a/R/bar.R +++ b/R/bar.R @@ -4,69 +4,133 @@ #' @param x A numeric column. #' @param y A character column or coercible as a character column. #' @param group Some grouping categorical column, e.g. administrative areas or population groups. -#' @param palette Palette name from 'pal_reach()'. -#' @param percent TRUE or FALSE. Should the x-labels be displayed as percentages? Default to TRUE. -#' @param reverse Boolean indicating whether the palette should be reversed. -#' @param family The font family for all plot's texts. Default to "Leelawadee". -#' @param alpha Transparency. -#' @param width Width. +#' @param flip TRUE or FALSE. Default to TRUE or horizontal bar plot. +#' @param percent TRUE or FALSE. Should the x-labels (and text labels if present) be displayed as percentages? Default to TRUE. +#' @param position Should the chart be stacked? Default to "dodge". Can take "dodge" and "stack". +#' @param alpha Fill transparency. #' @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_rev Reverse the color in the guide? Default to TRUE. -#' @param ... Other arguments to be passed to "ggblanket::gg_col" -#' -#' @description `ggblanket` as internals for deciding whether the bar chart is horizontally readable. +#' @param caption Plot caption. Default to NULL. +#' @param add_text TRUE or FALSE. Add the value as text. +#' @param add_text_suffix If percent is FALSE, should we add a suffix to the text label? +#' @param theme Whatever theme. Default to theme_reach(). #' #' @return A bar chart #' #' @export -bar_reach <- function(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, ...){ +bar <- function(df, x, y, group = NULL, flip = TRUE, percent = TRUE, position = "dodge", alpha = 1, x_title = NULL, y_title = NULL, group_title = NULL, title = NULL, subtitle = NULL, caption = NULL, add_text = FALSE, add_text_suffix = "", theme = theme_reach()){ - pal <- pal_reach(palette) + # To do : + # - automate bar width and text size, or at least give the flexibility and still center text + # - add facet possibility - if(is.null(pal)) rlang::warn( - c(paste0("There is no palette '", palette, "' for initiative 'reach'. Fallback to ggblanket's default color palette."), - "i" = paste0("Use `pal_reach(show_palettes = T)` to see the list of availabale palettes.") + # Prepare group, x and y names + # if (is.null(x_title)) x_title <- rlang::as_name(rlang::enquo(x)) + # if (is.null(y_title)) y_title <- rlang::as_name(rlang::enquo(y)) + # if (is.null(group_title)) group_title <- rlang::as_name(rlang::enquo(group)) + + # Mapping + g <- ggplot2::ggplot( + df, + mapping = ggplot2::aes(x = {{ x }}, y = {{ y }}, fill = {{ group }}, color = {{ group }} ) + ) + + # Add title, subtitle, caption, x_title, y_title + g <- g + ggplot2::labs( + title = title, + subtitle = subtitle, + caption = caption, + x = x_title, + y = y_title, + color = group_title, + fill = group_title ) - if (percent) x_labels <- scales::percent else x_labels <- NULL + width <- 0.5 + dodge_width <- 0.5 - pl <- df |> - ggblanket::gg_col(x = {{ x }}, - y = {{ y }}, - col = {{ group }}, - x_title = x_title, - x_labels = x_labels, - y_title = y_title, - col_title = group_title, - alpha = alpha, - width = width, - position = position, - title = title, - subtitle = subtitle, - caption = caption, - col_legend_place = legend_position, - theme = theme_reach( - palette = palette, - reverse = reverse, - family = family, - text_size = text_size, - title_size = title_size, - plot_background_pal = "#FFFFFF", - panel_background_pal = "#FFFFFF", - legend_reverse = legend_rev - ), - ... - ) + # Should the graph use position_fill? + if (position == "stack"){ + g <- g + ggplot2::geom_col( + alpha = alpha, + width = width, + position = ggplot2::position_stack() + ) + } else if (position == "dodge"){ + g <- g + ggplot2::geom_col( + alpha = alpha, + width = width, + position = ggplot2::position_dodge2( + width = dodge_width, + preserve = "single") + ) + } else{ + g <- g + ggplot2::geom_col( + alpha = alpha, + width = width + ) + } + # + # Labels to percent and expand scale + if (percent) { + g <- g + ggplot2::scale_y_continuous( + labels = scales::label_percent( + accuracy = 1, + decimal.mark = ",", + suffix = " %"), + expand = c(0.01, 0.1) + ) + } else { + g <- g + ggplot2::scale_y_continuous(expand = c(0.01, 0.1)) + } - return(pl) + # Because a text legend should always be horizontal, especially for an horizontal bar graph + if (flip){ + g <- g + ggplot2::coord_flip() + } + + # Add text to bars + if (flip) hjust_flip <- 1.5 else hjust_flip <- 0.5 + if (flip) vjust_flip <- 0.5 else vjust_flip <- 1.5 + + if (add_text & position != "dodge") { + rlang::abort("Adding text labels and positions different than dodges as not been implemented yet") + } + + # Add text labels + if (add_text) { + if (percent) { + g <- g + ggplot2::geom_text( + ggplot2::aes( + label = scales::label_percent( + accuracy = 1, + decimal.mark = ",", + suffix = " %")({{ y }}), + group = {{ group }}), + hjust = hjust_flip, + vjust = vjust_flip, + color = "white", + fontface = "bold", + position = ggplot2::position_dodge(width = dodge_width)) + } else { + g <- g + ggplot2::geom_text( + ggplot2::aes( + label = paste0(round({{ y }}), add_text_suffix), + group = {{ group }}), + hjust = hjust_flip, + vjust = vjust_flip, + color = "white", + fontface = "bold", + position = ggplot2::position_dodge(width = dodge_width)) + } + } + + # Add theme + g <- g + theme + + return(g) } diff --git a/R/cols_reach.R b/R/cols_reach.R index 2957e57..efb1c54 100644 --- a/R/cols_reach.R +++ b/R/cols_reach.R @@ -43,7 +43,7 @@ cols_reach <- function(..., unnamed = TRUE) { two_dots_flashy_1 = "gold1", two_dots_flashy_2 = "blue2", three_dots_1 = "aquamarine2", - three_dots_2 = "cornflowerbluer", + three_dots_2 = "cornflowerblue", three_dots_3 = "brown1", orpink = "#f8aa9b", pink = "#f5a6a7", diff --git a/R/point.R b/R/point.R index 7e7b551..3ef72c1 100644 --- a/R/point.R +++ b/R/point.R @@ -1,64 +1,81 @@ -#' @title Simple point chart +#' @title Simple bar chart #' #' @param df A data frame. #' @param x A numeric column. #' @param y A character column or coercible as a character column. #' @param group Some grouping categorical column, e.g. administrative areas or population groups. -#' @param palette Palette name from 'pal_reach()'. -#' @param reverse Boolean indicating whether the palette should be reversed. -#' @param family The font family for all plot's texts. Default to "Leelawadee". -#' @param alpha Transparency. -#' @param size Dot size. Default to 1.5. +#' @param flip TRUE or FALSE. Default to TRUE or horizontal bar plot. +#' @param alpha Fill transparency. +#' @param size Point size. #' @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 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 ... Other arguments to be passed to "ggblanket::gg_col" -#' -#' @description `ggblanket` as internals for deciding whether the bar chart is horizontally readable. +#' @param caption Plot caption. Default to NULL. +#' @param theme Whatever theme. Default to theme_reach(). #' #' @return A bar chart #' #' @export -point_reach <- function(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", ...){ +point <- function(df, x, y, group = NULL, flip = TRUE, alpha = 1, size = 1, x_title = NULL, y_title = NULL, group_title = NULL, title = NULL, subtitle = NULL, caption = NULL, theme = theme_reach()){ - pal <- pal_reach(palette) + # To do : + # - automate bar width and text size, or at least give the flexibility and still center text + # - add facet possibility - if(is.null(pal)) rlang::warn( - c(paste0("There is no palette '", palette, "' for initiative 'reach'. Fallback to ggblanket's default color palette."), - "i" = paste0("Use `pal_reach(show_palettes = T)` to see the list of availabale palettes.") + # Prepare group, x and y names + # if (is.null(x_title)) x_title <- rlang::as_name(rlang::enquo(x)) + # if (is.null(y_title)) y_title <- rlang::as_name(rlang::enquo(y)) + # if (is.null(group_title)) group_title <- rlang::as_name(rlang::enquo(group)) + + # Mapping + g <- ggplot2::ggplot( + df, + mapping = ggplot2::aes(x = {{ x }}, y = {{ y }}, fill = {{ group }}, color = {{ group }} ) ) - pl <- df |> - ggblanket::gg_point(x = {{ x }}, - y = {{ y }}, - col = {{ group }}, - x_title = x_title, - y_title = y_title, - col_title = group_title, - alpha = alpha, - size = size, - title = title, - subtitle = subtitle, - caption = caption, - col_legend_place = legend_position, - theme = theme_reach( - palette = palette, - reverse = reverse, - family = family, - text_size = text_size, - title_size = title_size, - plot_background_pal = "#FFFFFF", - panel_background_pal = "#FFFFFF" - ), - ... + # Add title, subtitle, caption, x_title, y_title + g <- g + ggplot2::labs( + title = title, + subtitle = subtitle, + caption = caption, + x = x_title, + y = y_title, + color = group_title, + fill = group_title + ) + + width <- 0.5 + dodge_width <- 0.5 + + # Should the graph use position_fill? + g <- g + ggplot2::geom_point( + alpha = alpha, + size = size ) - return(pl) + # Labels to percent and expand scale + # if (percent) { + # g <- g + ggplot2::scale_y_continuous( + # labels = scales::label_percent( + # accuracy = 1, + # decimal.mark = ",", + # suffix = " %"), + # expand = c(0.01, 0.1) + # ) + # } else { + # g <- g + ggplot2::scale_y_continuous(expand = c(0.01, 0.1)) + # } + + # # Because a text legend should always be horizontal, especially for an horizontal bar graph + if (flip){ + g <- g + ggplot2::coord_flip() + } + + # Add theme + g <- g + theme + + return(g) } diff --git a/R/theme_reach.R b/R/theme_reach.R index fe5601b..254f5e9 100644 --- a/R/theme_reach.R +++ b/R/theme_reach.R @@ -3,15 +3,25 @@ #' @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 family The font family for all plot's texts. Default to "Leelawadee". +#' @param font_family The font family for all plot's texts. Default to "Leelawadee". +#' @param title_size The size of the title. Defaults to 12. +#' @param title_color Title color. +#' @param title_font_face Title font face. Default to "bold". Font face ("plain", "italic", "bold", "bold.italic"). #' @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. -#' @param plot_background_pal The color for the plot background color. Default to white. -#' @param panel_background_pal The color for the panel background color. Default to white. +#' @param text_color Text color. +#' @param text_font_face Text font face. Default to "bold". Font face ("plain", "italic", "bold", "bold.italic"). +#' @param panel_background_color 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 ... Additional arguments passed to `ggblanket::gg_theme()`. +#' @param axis_x Boolean. Do you need x-axis? +#' @param axis_y Boolean. Do you need y-axis? +#' @param grid_x Boolean. Do you need major grid lines for x-axis? +#' @param grid_y Boolean. Do you need major grid lines for y-axis? +#' @param grid_x_size X line size. +#' @param grid_y_size Y line size. +#' @param grid_color Grid lines color. +#' @param ... Additional arguments passed to `ggplot2::gg_theme()`. #' #' #' @description Give some reach colors and fonts to a ggplot. @@ -23,33 +33,126 @@ theme_reach <- function( palette = "main", discrete = TRUE, reverse = FALSE, - family = "Leelawadee", + font_family = "Leelawadee", + title_size = 12, + title_color = cols_reach("main_grey"), + title_font_face = "bold", text_size = 10, - title_size = 14, - plot_background_pal = "#FFFFFF", - panel_background_pal = "#FFFFFF", + text_color = cols_reach("main_grey"), + text_font_face = "bold", + panel_background_color = "#FFFFFF", legend_position = "right", legend_direction = "vertical", legend_reverse = TRUE, + axis_x = TRUE, + axis_y = TRUE, + grid_x = FALSE, + grid_y = FALSE, + grid_color = cols_reach("main_lt_grey"), + grid_x_size = 0.1, + grid_y_size = 0.1, ... ) { + # To do : + # - add facet theming + # Basic simple theme - theme_reach <- ggblanket::gg_theme( - text_family = family, - text_size = text_size, - title_size = title_size, - plot_background_pal = plot_background_pal, - panel_background_pal = panel_background_pal) + # theme_reach <- ggplot2::theme_bw() + + theme_reach <- ggplot2::theme( + # Title - design + title = ggplot2::element_text( + family = font_family, + color = title_color, + size = title_size, + face = title_font_face + ), + # Text - design + text = ggplot2::element_text( + family = font_family, + color = text_color, + size = text_size, + face = text_font_face + ), + # Default legend to right position + legend.position = legend_position, + # Defaut legend to vertical direction + legend.direction = legend_direction, + # set panel background color + panel.background = ggplot2::element_rect( + fill = panel_background_color + ), + # Remove minor grid lines + panel.grid.minor.x = ggplot2::element_blank(), + panel.grid.minor.y = ggplot2::element_blank(), + # Remove background for legend key + legend.key = ggplot2::element_blank() + ) + + # Axis lines ? + if (axis_x & axis_y) { + theme_reach <- theme_reach + + ggplot2::theme( + axis.line = ggplot2::element_line(color = text_color)) + } + + if (!axis_x) { + theme_reach <- theme_reach + + ggplot2::theme( + axis.line.x = ggplot2::element_blank(), + axis.ticks.x = ggplot2::element_blank(), + axis.text.x = ggplot2::element_blank()) + } + + if (!axis_y) { + theme_reach <- theme_reach + + ggplot2::theme( + axis.line.y = ggplot2::element_blank(), + axis.ticks.y = ggplot2::element_blank(), + axis.text.y = ggplot2::element_blank()) + } + + # X - major grid lines + if (!grid_x) theme_reach <- theme_reach + + ggplot2::theme( + panel.grid.major.x = ggplot2::element_blank() + ) else theme_reach <- theme_reach + + ggplot2::theme( + panel.grid.major.x = ggplot2::element_line( + color = grid_color, + linewidth = grid_y_size) + ) + + # Y - major grid lines + if (!grid_y) theme_reach <- theme_reach + + ggplot2::theme( + panel.grid.major.y = ggplot2::element_blank() + ) else theme_reach <- theme_reach + + ggplot2::theme( + panel.grid.major.y = ggplot2::element_line( + color = grid_color, + linewidth = grid_y_size) + ) + + # Other parameters + theme_reach <- theme_reach + ggplot2::theme(...) - # Default legend to right position - theme_reach <- theme_reach + - ggplot2::theme(legend.position = legend_position) + # Check if palette is an actual existing palette + pal <- pal_reach(palette) - # Defaut legend to vertical direction - theme_reach <- theme_reach + - ggplot2::theme(legend.direction = legend_direction) + if(is.null(pal)) { + rlang::warn( + c( + paste0("There is no palette '", palette, "' for initiative 'reach'. Fallback to REACH main palette."), + "i" = paste0("Use `pal_reach(show_palettes = TRUE)` to see the list of availabale palettes.") + ) + ) + + palette <- "main" + + } # Add reach color palettes by default # (reversed guide is defaulted to TRUE for natural reading) diff --git a/README.Rmd b/README.Rmd index ae39c52..16cdf8e 100644 --- a/README.Rmd +++ b/README.Rmd @@ -11,7 +11,9 @@ knitr::opts_chunk$set( fig.path = "man/figures/README-", out.width = "100%", warning = FALSE, - message = FALSE + message = FALSE, + dpi = 300, + dev.args = list(type = "cairo") ) desc = read.dcf('DESCRIPTION') @@ -83,11 +85,15 @@ df <- penguins |> mean_fl = mean(flipper_length_mm, na.rm = T)) |> ungroup() -# Simple bar chart by group -bar_reach(df, mean_bl, island, species, percent = FALSE, x_title = "Mean of bill length") +# Simple bar chart by group with some alpha transparency +bar(df, island, mean_bl, species, percent = FALSE, alpha = 0.6, x_title = "Mean of bill length") + +# Using another color palette through `theme_reach()` and changing scale to percent +bar(df, island,mean_bl, species, percent = TRUE, theme = theme_reach(palette = "artichoke_3")) + +# Not flipped, with text added, group_title, no y-axis and no bold for legend +bar(df, island, mean_bl, species, group_title = "Species", flip = FALSE, add_text = TRUE, add_text_suffix = "%", percent = FALSE, theme = theme_reach(text_font_face = "plain", axis_y = FALSE)) -# Using another color palette -bar_reach(df, mean_bl, island, species, percent = FALSE, palette = "artichoke_3", legend_rev = TRUE) ``` ### Example 2: Point chart, already REACH themed @@ -97,13 +103,13 @@ At this stage, `point_reach()` only supports categorical grouping colors with th ```{r example-point-chart, eval = TRUE} # Simple point chart -point_reach(penguins, bill_length_mm, flipper_length_mm) +point(penguins, bill_length_mm, flipper_length_mm) # Point chart with grouping colors, greater dot size, some transparency, reversed color palette -point_reach(penguins, bill_length_mm, flipper_length_mm, island, alpha = 0.6, size = 3, reverse = TRUE) +point(penguins, bill_length_mm, flipper_length_mm, island, alpha = 0.6, size = 3, theme = theme_reach(reverse = TRUE)) # Using another color palettes -point_reach(penguins, bill_length_mm, flipper_length_mm, island, palette = "artichoke_3") +point(penguins, bill_length_mm, flipper_length_mm, island, size = 1.5, x_title = "Bill", y_title = "Flipper", title = "Length (mm)", theme = theme_reach(palette = "artichoke_3", text_font_face = , grid_x = T)) ``` ## Maps diff --git a/README.md b/README.md index 2fec6ca..79104a1 100644 --- a/README.md +++ b/README.md @@ -89,20 +89,28 @@ df <- penguins |> mean_fl = mean(flipper_length_mm, na.rm = T)) |> ungroup() -# Simple bar chart by group -bar_reach(df, mean_bl, island, species, percent = FALSE, x_title = "Mean of bill length") +# Simple bar chart by group with some alpha transparency +bar(df, island, mean_bl, species, percent = FALSE, alpha = 0.6, x_title = "Mean of bill length") ``` ``` r -# Using another color palette -bar_reach(df, mean_bl, island, species, percent = FALSE, palette = "artichoke_3", legend_rev = TRUE) +# Using another color palette through `theme_reach()` and changing scale to percent +bar(df, island,mean_bl, species, percent = TRUE, theme = theme_reach(palette = "artichoke_3")) ``` +``` r + +# Not flipped, with text added, group_title, no y-axis and no bold for legend +bar(df, island, mean_bl, species, group_title = "Species", flip = FALSE, add_text = TRUE, add_text_suffix = "%", percent = FALSE, theme = theme_reach(text_font_face = "plain", axis_y = FALSE)) +``` + + + ### Example 2: Point chart, already REACH themed At this stage, `point_reach()` only supports categorical grouping colors @@ -111,7 +119,7 @@ with the `group` arg. ``` r # Simple point chart -point_reach(penguins, bill_length_mm, flipper_length_mm) +point(penguins, bill_length_mm, flipper_length_mm) ``` @@ -119,7 +127,7 @@ point_reach(penguins, bill_length_mm, flipper_length_mm) ``` r # Point chart with grouping colors, greater dot size, some transparency, reversed color palette -point_reach(penguins, bill_length_mm, flipper_length_mm, island, alpha = 0.6, size = 3, reverse = TRUE) +point(penguins, bill_length_mm, flipper_length_mm, island, alpha = 0.6, size = 3, theme = theme_reach(reverse = TRUE)) ``` @@ -127,7 +135,7 @@ point_reach(penguins, bill_length_mm, flipper_length_mm, island, alpha = 0.6, si ``` r # Using another color palettes -point_reach(penguins, bill_length_mm, flipper_length_mm, island, palette = "artichoke_3") +point(penguins, bill_length_mm, flipper_length_mm, island, size = 1.5, x_title = "Bill", y_title = "Flipper", title = "Length (mm)", theme = theme_reach(palette = "artichoke_3", text_font_face = , grid_x = T)) ``` diff --git a/docs/404.html b/docs/404.html index c75726d..b309118 100644 --- a/docs/404.html +++ b/docs/404.html @@ -13,8 +13,8 @@ - - + + @@ -31,7 +31,7 @@ visualizeR - 0.3.9000 + 0.4.9000 + + + + + +
+
+
+ +
+

Simple bar chart

+
+ +
+

Usage

+
bar(
+  df,
+  x,
+  y,
+  group = NULL,
+  flip = TRUE,
+  percent = TRUE,
+  position = "dodge",
+  alpha = 1,
+  x_title = NULL,
+  y_title = NULL,
+  group_title = NULL,
+  title = NULL,
+  subtitle = NULL,
+  caption = NULL,
+  add_text = FALSE,
+  add_text_suffix = "",
+  theme = theme_reach()
+)
+
+ +
+

Arguments

+
df
+

A data frame.

+ + +
x
+

A numeric column.

+ + +
y
+

A character column or coercible as a character column.

+ + +
group
+

Some grouping categorical column, e.g. administrative areas or population groups.

+ + +
flip
+

TRUE or FALSE. Default to TRUE or horizontal bar plot.

+ + +
percent
+

TRUE or FALSE. Should the x-labels (and text labels if present) be displayed as percentages? Default to TRUE.

+ + +
position
+

Should the chart be stacked? Default to "dodge". Can take "dodge" and "stack".

+ + +
alpha
+

Fill transparency.

+ + +
x_title
+

The x scale title. Default to NULL.

+ + +
y_title
+

The y scale title. Default to NULL.

+ + +
group_title
+

The group legend title. Default to NULL.

+ + +
title
+

Plot title. Default to NULL.

+ + +
subtitle
+

Plot subtitle. Default to NULL.

+ + +
caption
+

Plot caption. Default to NULL.

+ + +
add_text
+

TRUE or FALSE. Add the value as text.

+ + +
add_text_suffix
+

If percent is FALSE, should we add a suffix to the text label?

+ + +
theme
+

Whatever theme. Default to theme_reach().

+ +
+
+

Value

+ + +

A bar chart

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/bar_reach.html b/docs/reference/bar_reach.html deleted file mode 100644 index 4227377..0000000 --- a/docs/reference/bar_reach.html +++ /dev/null @@ -1,196 +0,0 @@ - -Simple bar chart — bar_reach • visualizeR - Skip to contents - - -
-
-
- -
-

`ggblanket` as internals for deciding whether the bar chart is horizontally readable.

-
- -
-

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

Arguments

-
df
-

A data frame.

- - -
x
-

A numeric column.

- - -
y
-

A character column or coercible as a character column.

- - -
group
-

Some grouping categorical column, e.g. administrative areas or population groups.

- - -
percent
-

TRUE or FALSE. Should the x-labels be displayed as percentages? Default to TRUE.

- - -
palette
-

Palette name from 'pal_reach()'.

- - -
reverse
-

Boolean indicating whether the palette should be reversed.

- - -
family
-

The font family for all plot's texts. Default to "Leelawadee".

- - -
alpha
-

Transparency.

- - -
width
-

Width.

- - -
x_title
-

The x scale title. Default to NULL.

- - -
y_title
-

The y scale title. Default to NULL.

- - -
group_title
-

The group legend title. Default to NULL.

- - -
position
-

Should the chart be stacked? Default to "dodge". Can take "dodge" and "stack".

- - -
title
-

Plot title. Default to NULL.

- - -
subtitle
-

Plot subtitle. Default to NULL.

- - -
caption
-

Caption title string. Default to NULL.

- - -
text_size
-

The size of all text other than the title, subtitle and caption. Defaults to 10.

- - -
title_size
-

The size of the title text. Defaults to 14.

- - -
legend_position
-

Position of the legend; Default to "right". Can take "right", "left", "top", "bottom" or "none".

- - -
legend_rev
-

Reverse the color in the guide? Default to TRUE.

- - -
...
-

Other arguments to be passed to "ggblanket::gg_col"

- -
-
-

Value

- - -

A bar chart

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/border_admin0.html b/docs/reference/border_admin0.html index 91e1989..8973dda 100644 --- a/docs/reference/border_admin0.html +++ b/docs/reference/border_admin0.html @@ -1,5 +1,5 @@ -Haïti border. — border_admin0 • visualizeRHaïti border. — border_admin0 • visualizeR @@ -10,7 +10,7 @@ visualizeR - 0.3.9000 + 0.4.9000 + + + + + +
+
+
+ +
+

Simple bar chart

+
+ +
+

Usage

+
point(
+  df,
+  x,
+  y,
+  group = NULL,
+  flip = TRUE,
+  alpha = 1,
+  size = 1,
+  x_title = NULL,
+  y_title = NULL,
+  group_title = NULL,
+  title = NULL,
+  subtitle = NULL,
+  caption = NULL,
+  theme = theme_reach()
+)
+
+ +
+

Arguments

+
df
+

A data frame.

+ + +
x
+

A numeric column.

+ + +
y
+

A character column or coercible as a character column.

+ + +
group
+

Some grouping categorical column, e.g. administrative areas or population groups.

+ + +
flip
+

TRUE or FALSE. Default to TRUE or horizontal bar plot.

+ + +
alpha
+

Fill transparency.

+ + +
size
+

Point size.

+ + +
x_title
+

The x scale title. Default to NULL.

+ + +
y_title
+

The y scale title. Default to NULL.

+ + +
group_title
+

The group legend title. Default to NULL.

+ + +
title
+

Plot title. Default to NULL.

+ + +
subtitle
+

Plot subtitle. Default to NULL.

+ + +
caption
+

Plot caption. Default to NULL.

+ + +
theme
+

Whatever theme. Default to theme_reach().

+ +
+
+

Value

+ + +

A bar chart

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/point_reach.html b/docs/reference/point_reach.html deleted file mode 100644 index 36bbf52..0000000 --- a/docs/reference/point_reach.html +++ /dev/null @@ -1,181 +0,0 @@ - -Simple point chart — point_reach • visualizeR - Skip to contents - - -
-
-
- -
-

`ggblanket` as internals for deciding whether the bar chart is horizontally readable.

-
- -
-

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",
-  ...
-)
-
- -
-

Arguments

-
df
-

A data frame.

- - -
x
-

A numeric column.

- - -
y
-

A character column or coercible as a character column.

- - -
group
-

Some grouping categorical column, e.g. administrative areas or population groups.

- - -
palette
-

Palette name from 'pal_reach()'.

- - -
reverse
-

Boolean indicating whether the palette should be reversed.

- - -
family
-

The font family for all plot's texts. Default to "Leelawadee".

- - -
alpha
-

Transparency.

- - -
size
-

Dot size. Default to 1.5.

- - -
x_title
-

The x scale title. Default to NULL.

- - -
y_title
-

The y scale title. Default to NULL.

- - -
group_title
-

The group legend title. Default to NULL.

- - -
title
-

Plot title. Default to NULL.

- - -
subtitle
-

Plot subtitle. Default to NULL.

- - -
caption
-

Caption title string. Default to NULL.

- - -
text_size
-

The size of all text other than the title, subtitle and caption. Defaults to 10.

- - -
title_size
-

The size of the title text. Defaults to 14.

- - -
legend_position
-

Position of the legend; Default to "right". Can take "right", "left", "top", "bottom" or "none".

- - -
...
-

Other arguments to be passed to "ggblanket::gg_col"

- -
-
-

Value

- - -

A bar chart

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/scale_color.html b/docs/reference/scale_color.html index 8fb6028..7f0e05a 100644 --- a/docs/reference/scale_color.html +++ b/docs/reference/scale_color.html @@ -1,5 +1,5 @@ -Color scale constructor for REACH or AGORA colors — scale_color • visualizeRColor scale constructor for REACH or AGORA colors — scale_color • visualizeR @@ -10,7 +10,7 @@ visualizeR - 0.3.9000 + 0.4.9000