Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhodge931 committed Dec 13, 2024
1 parent 3f365cd commit 7c75df3
Show file tree
Hide file tree
Showing 20 changed files with 445 additions and 196 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# ggblanket 11.0.0.9000

* Rethought `set_blanket` and `weave_geom_defaults` arguments.
* Added R 4.2.0 dependency.
* Removed `aes_colour_darken`, `aes_colour_lighten`, `aes_fill_darken` and `aes_colour_lighten`.
* Removed `gg_ribbon`, `gg_boxplot`, `gg_crossbar` and `gg_smooth` alpha default to `NA`.
* Added colour blending (e.g. `blend = "multiply`).
* Added `gg_ribbon_line`.
* Updated `*_mode_*` themes to default to `axis_line_linewidth = 0.25`.
* From `set_blanket`, removed `reference_*` arguments and replaced with `hline_*` and `vline_*` arguments.

# ggblanket 11.0.0

Expand Down
216 changes: 216 additions & 0 deletions R/gg_col_errorbar.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
#' #' Lineribbon ggplot
#' #'
#' #' @description Create a lineribbon ggplot with a wrapper around [ggplot2::ggplot()] + [geom_ribbon()][ggplot2::geom_ribbon()] + [geom_line()][ggplot2::geom_line()]
#' #'
#' #' @inheritParams gg_blanket
#' #'
#' #' @return A ggplot object.
#' #' @export
#' #'
#' #' @examples
#' #' library(ggplot2)
#' #' library(dplyr)
#' #'
#' #' set_blanket()
#' #'
#' #' data.frame(year = 1875:1972, level = as.vector(LakeHuron)) |>
#' #' mutate(level_min = level - 1, level_max = level + 1) |>
#' #' gg_ribbon_line(
#' #' x = year,
#' #' y = level,
#' #' ymin = level_min,
#' #' ymax = level_max,
#' #' x_labels = \(x) x,
#' #' blend = "multiply",
#' #' )
#' #'
#' gg_col_errorbar <- function(data = NULL,
#' ...,
#' stat = "identity",
#' position = "identity",
#' coord = ggplot2::coord_cartesian(clip = "off"),
#' mode = NULL, mode_orientation = NULL, blend = NULL,
#' x = NULL,
#' xmin = NULL,
#' xmax = NULL,
#' xend = NULL,
#' y = NULL,
#' ymin = NULL,
#' ymax = NULL,
#' yend = NULL,
#' z = NULL,
#' col = NULL,
#' facet = NULL,
#' facet2 = NULL,
#' group = NULL,
#' subgroup = NULL,
#' label = NULL,
#' text = NULL,
#' sample = NULL,
#' mapping = NULL,
#' x_breaks = NULL, x_breaks_n = NULL,
#' x_expand = NULL,
#' x_expand_limits = NULL,
#' x_label = NULL, x_labels = NULL,
#'
#'
#' x_position = "bottom",
#'
#' x_sec_axis = ggplot2::waiver(), x_symmetric = NULL, x_transform = NULL,
#' y_breaks = NULL, y_breaks_n = NULL,
#' y_expand = NULL,
#' y_expand_limits = NULL,
#' y_label = NULL, y_labels = NULL,
#' y_position = "left",
#' y_sec_axis = ggplot2::waiver(),
#' y_symmetric = NULL,
#'
#' y_transform = NULL,
#' col_breaks = NULL, col_breaks_n = 5,
#' col_drop = FALSE,
#' col_expand_limits = NULL,
#' col_label = NULL, col_labels = NULL,
#' col_legend_ncol = NULL,
#' col_legend_nrow = NULL,
#' col_legend_rev = FALSE,
#'
#'
#' col_palette = NULL,
#' col_palette_na = NULL,
#' col_rescale = scales::rescale(),
#' col_steps = FALSE,
#'
#' col_transform = NULL,
#' facet_axes = NULL,
#' facet_axis_labels = "margins",
#' facet_drop = FALSE,
#' facet_labels = NULL,
#' facet_layout = NULL,
#' facet_ncol = NULL,
#' facet_nrow = NULL,
#' facet_scales = "fixed",
#' facet_space = "fixed",
#' title = NULL,
#' subtitle = NULL,
#' caption = NULL,
#' label_to_case = snakecase::to_sentence_case) {
#' plot <- gg_blanket(
#' data = data,
#' geom = "blank",
#' stat = stat,
#' position = position,
#' coord = coord,
#' mode = mode, mode_orientation = mode_orientation, blend = blend,
#' x = {{ x }},
#' y = {{ y }},
#' xmin = {{ xmin }},
#' xmax = {{ xmax }},
#' xend = {{ xend }},
#' ymin = {{ ymin }},
#' ymax = {{ ymax }},
#' yend = {{ yend }},
#' z = {{ z }},
#' col = {{ col }},
#' facet = {{ facet }},
#' facet2 = {{ facet2 }},
#' group = {{ group }},
#' subgroup = {{ subgroup }},
#' label = {{ label }},
#' text = {{ text }},
#' sample = {{ sample }},
#' mapping = mapping,
#' x_breaks = x_breaks,
#' x_expand = x_expand,
#' x_expand_limits = x_expand_limits,
#' x_labels = x_labels,
#' x_breaks_n = x_breaks_n,
#' x_sec_axis = x_sec_axis,
#' x_symmetric = x_symmetric, x_position = x_position,
#' x_label = x_label,
#' x_transform = x_transform,
#' y_breaks = y_breaks,
#' y_expand = y_expand,
#' y_expand_limits = y_expand_limits,
#' y_labels = y_labels,
#' y_breaks_n = y_breaks_n,
#' y_sec_axis = y_sec_axis,
#' y_symmetric = y_symmetric, y_position = y_position,
#' y_label = y_label,
#' y_transform = y_transform,
#' col_breaks = col_breaks,
#' col_drop = col_drop,
#' col_expand_limits = col_expand_limits,
#' col_labels = col_labels,
#' col_legend_ncol = col_legend_ncol,
#' col_legend_nrow = col_legend_nrow,
#' col_legend_rev = col_legend_rev,
#' col_breaks_n = col_breaks_n,
#'
#' col_palette = col_palette,
#' col_palette_na = col_palette_na,
#' col_rescale = col_rescale,
#' col_steps = col_steps,
#' col_label = col_label,
#' col_transform = col_transform,
#' facet_axes = facet_axes,
#' facet_axis_labels = facet_axis_labels,
#' facet_drop = facet_drop,
#' facet_labels = facet_labels,
#' facet_layout = facet_layout,
#' facet_ncol = facet_ncol,
#' facet_nrow = facet_nrow,
#' facet_scales = facet_scales,
#' facet_space = facet_space,
#' title = title,
#' subtitle = subtitle,
#' caption = caption,
#' label_to_case = label_to_case,
#' ...
#' )
#'
#' if (rlang::is_null(blend)) {
#' plot +
#' list(
#' ggplot2::layer(
#' geom = "bar",
#' stat = stat,
#' position = position,
#' mapping = ggplot2::aes(!!!mapping),
#' params = rlang::list2(...),
#' # show.legend = show_legend,
#' ),
#' ggplot2::layer(
#' geom = "errorbar",
#' stat = stat,
#' position = position,
#' mapping = ggplot2::aes(!!!mapping),
#' params = rlang::list2(...),
#' # show.legend = show_legend,
#' )
#' )
#' }
#' else {
#' plot +
#' ggblend::blend(
#' list(
#' ggplot2::layer(
#' geom = "bar",
#' stat = stat,
#' position = position,
#' mapping = ggplot2::aes(!!!mapping),
#' params = rlang::list2(...),
#' # show.legend = show_legend,
#' ) |> ggblend::blend(blend = blend),
#' ggplot2::layer(
#' geom = "errorbar",
#' stat = stat,
#' position = position,
#' mapping = ggplot2::aes(!!!mapping),
#' params = rlang::list2(...),
#' # show.legend = show_legend,
#' ) |> ggblend::blend(blend = blend)
#' ), blend = blend
#' )
#'
#' }
#' }
25 changes: 12 additions & 13 deletions R/gg_label.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#' gg_label(
#' x = model,
#' y = mpg,
#' col = mpg,
#' label = model,
#' y_expand_limits = 0,
#' y_label = "Miles per gallon",
Expand Down Expand Up @@ -52,23 +51,23 @@ gg_label <- function(data = NULL,
text = NULL,
sample = NULL,
mapping = NULL,
x_breaks = NULL, x_breaks_n = NULL,
x_breaks = NULL, x_breaks_n = NULL,
x_expand = NULL,
x_expand_limits = NULL,
x_label = NULL, x_labels = NULL,
x_position = "bottom",
x_label = NULL, x_labels = NULL,


x_position = "bottom",

x_sec_axis = ggplot2::waiver(), x_symmetric = NULL, x_transform = NULL,
y_breaks = NULL, y_breaks_n = NULL,
y_expand = NULL,
y_expand_limits = NULL,
y_label = NULL, y_labels = NULL,
y_position = "left",
y_sec_axis = ggplot2::waiver(),
y_symmetric = NULL,
y_symmetric = NULL,

y_transform = NULL,
col_breaks = NULL, col_breaks_n = 5,
col_drop = FALSE,
Expand All @@ -77,13 +76,13 @@ gg_label <- function(data = NULL,
col_legend_ncol = NULL,
col_legend_nrow = NULL,
col_legend_rev = FALSE,


col_palette = NULL,
col_palette_na = NULL,
col_rescale = scales::rescale(),
col_steps = FALSE,

col_transform = NULL,
facet_axes = NULL,
facet_axis_labels = "margins",
Expand Down Expand Up @@ -149,7 +148,7 @@ gg_label <- function(data = NULL,
col_legend_nrow = col_legend_nrow,
col_legend_rev = col_legend_rev,
col_breaks_n = col_breaks_n,

col_palette = col_palette,
col_palette_na = col_palette_na,
col_rescale = col_rescale,
Expand Down
25 changes: 12 additions & 13 deletions R/gg_text.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#' gg_text(
#' x = model,
#' y = mpg,
#' col = mpg,
#' label = model,
#' y_expand_limits = 0,
#' y_label = "Miles per gallon",
Expand Down Expand Up @@ -52,23 +51,23 @@ gg_text <- function(data = NULL,
text = NULL,
sample = NULL,
mapping = NULL,
x_breaks = NULL, x_breaks_n = NULL,
x_breaks = NULL, x_breaks_n = NULL,
x_expand = NULL,
x_expand_limits = NULL,
x_label = NULL, x_labels = NULL,
x_position = "bottom",
x_label = NULL, x_labels = NULL,


x_position = "bottom",

x_sec_axis = ggplot2::waiver(), x_symmetric = NULL, x_transform = NULL,
y_breaks = NULL, y_breaks_n = NULL,
y_expand = NULL,
y_expand_limits = NULL,
y_label = NULL, y_labels = NULL,
y_position = "left",
y_sec_axis = ggplot2::waiver(),
y_symmetric = NULL,
y_symmetric = NULL,

y_transform = NULL,
col_breaks = NULL, col_breaks_n = 5,
col_drop = FALSE,
Expand All @@ -77,13 +76,13 @@ gg_text <- function(data = NULL,
col_legend_ncol = NULL,
col_legend_nrow = NULL,
col_legend_rev = FALSE,


col_palette = NULL,
col_palette_na = NULL,
col_rescale = scales::rescale(),
col_steps = FALSE,

col_transform = NULL,
facet_axes = NULL,
facet_axis_labels = "margins",
Expand Down Expand Up @@ -149,7 +148,7 @@ gg_text <- function(data = NULL,
col_legend_nrow = col_legend_nrow,
col_legend_rev = col_legend_rev,
col_breaks_n = col_breaks_n,

col_palette = col_palette,
col_palette_na = col_palette_na,
col_rescale = col_rescale,
Expand Down
Loading

0 comments on commit 7c75df3

Please sign in to comment.