Create a blank ggplot with a wrapper around ggplot2::geom_blank().
Usage
gg_blank(
data = NULL,
x = NULL,
y = NULL,
col = NULL,
facet = NULL,
facet2 = NULL,
group = NULL,
xmin = NULL,
xmax = NULL,
xend = NULL,
ymin = NULL,
ymax = NULL,
yend = NULL,
z = NULL,
sample = NULL,
label = NULL,
subgroup = NULL,
mapping = NULL,
stat = "identity",
position = "identity",
coord = ggplot2::coord_cartesian(clip = "off"),
pal = NULL,
pal_na = "#bebebe",
...,
title = NULL,
subtitle = NULL,
x_breaks = NULL,
x_expand = NULL,
x_gridlines = NULL,
x_include = NULL,
x_labels = NULL,
x_limits = NULL,
x_oob = scales::oob_keep,
x_sec_axis = ggplot2::waiver(),
x_title = NULL,
x_trans = "identity",
y_breaks = NULL,
y_expand = NULL,
y_gridlines = NULL,
y_include = NULL,
y_labels = NULL,
y_limits = NULL,
y_oob = scales::oob_keep,
y_sec_axis = ggplot2::waiver(),
y_title = NULL,
y_trans = "identity",
col_breaks = NULL,
col_continuous = "gradient",
col_include = NULL,
col_labels = NULL,
col_legend_place = NULL,
col_legend_ncol = NULL,
col_legend_nrow = NULL,
col_legend_rev = FALSE,
col_limits = NULL,
col_oob = scales::oob_keep,
col_rescale = scales::rescale(),
col_scale = NULL,
col_title = NULL,
col_trans = "identity",
facet_labels = NULL,
facet_ncol = NULL,
facet_nrow = NULL,
facet_scales = "fixed",
facet_space = "fixed",
facet_layout = NULL,
facet_switch = NULL,
linetype_title = NULL,
shape_title = NULL,
size_title = NULL,
caption = NULL,
titles = snakecase::to_sentence_case,
theme = NULL
)
Arguments
- data
A data frame or tibble.
- x
Unquoted x aesthetic variable.
- y
Unquoted y aesthetic variable.
- col
Unquoted col and fill aesthetic variable.
- facet
Unquoted facet aesthetic variable.
- facet2
Unquoted second facet variable.
- group
Unquoted group aesthetic variable.
- xmin
Unquoted xmin aesthetic variable.
- xmax
Unquoted xmax aesthetic variable.
- xend
Unquoted xend aesthetic variable.
- ymin
Unquoted ymin aesthetic variable.
- ymax
Unquoted ymax aesthetic variable.
- yend
Unquoted yend aesthetic variable.
- z
Unquoted z aesthetic variable.
- sample
Unquoted sample aesthetic variable.
- label
Unquoted label aesthetic variable.
- subgroup
Unquoted subgroup aesthetic variable.
- mapping
Map additional aesthetics using the ggplot2::aes function (e.g. shape). Excludes colour, fill or alpha.
- stat
A ggplot2 character string stat.
- position
Position adjustment. Either a character string (e.g."identity"), or a function (e.g. ggplot2::position_identity()).
- coord
A coordinate function from ggplot2 (e.g. ggplot2::coord_cartesian(clip = "off")).
- pal
Colours to use. A character vector of hex codes (or names).
- pal_na
Colour to use for NA values. A character vector of a hex code (or name).
- ...
Other arguments passed to the ggplot2::geom_blank function.
- title
Title string.
- subtitle
Subtitle string.
- x_breaks
A scales::breaks_* function (e.g. scales::breaks_pretty()), or a vector of breaks.
- x_expand
Padding to the limits with the ggplot2::expansion function, or a vector of length 2 (e.g. c(0, 0)).
- x_gridlines
TRUE or FALSE for vertical x gridlines. NULL guesses based on the classes of the x and y.
- x_include
For a continuous x variable, any values that the limits should encompass (e.g. 0).
- x_labels
A function that takes the breaks as inputs (e.g. scales::label_comma()), or a vector of labels.
- x_limits
A vector of length 2 to determine the limits of the axis.
- x_oob
For a continuous x variable, a scales::oob_* function of how to handle values outside of limits (e.g. scales::oob_keep). Defaults to scales::oob_keep.
- x_sec_axis
A secondary axis using the ggplot2::sec_axis or ggplot2::dup_axis function.
- x_title
Axis title string. Use "" for no title.
- x_trans
For a numeric x variable, a transformation object (e.g. "log10", "sqrt" or "reverse").
- y_breaks
A scales::breaks_* function (e.g. scales::breaks_pretty()), or a vector of breaks.
- y_expand
Padding to the limits with the ggplot2::expansion function, or a vector of length 2 (e.g. c(0, 0)).
- y_gridlines
TRUE or FALSE of horizontal y gridlines. NULL guesses based on the classes of the x and y.
- y_include
For a continuous y variable, any values that the limits should encompass (e.g. 0).
- y_labels
A function that takes the breaks as inputs (e.g. scales::label_comma()), or a vector of labels.
- y_limits
A vector of length 2 to determine the limits of the axis.
- y_oob
For a continuous y variable, a scales::oob_* function of how to handle values outside of limits (e.g. scales::oob_keep). Defaults to scales::oob_keep.
- y_sec_axis
A secondary axis using the ggplot2::sec_axis or ggplot2::dup_axis function.
- y_title
Axis title string. Use "" for no title.
- y_trans
For a numeric y variable, a transformation object (e.g. "log10", "sqrt" or "reverse").
- col_breaks
A scales::breaks_* function (e.g. scales::breaks_pretty()), or a vector of breaks.
- col_continuous
For a continuous col variable, the type of colouring. Either "gradient" or "steps". Defaults to "gradient".
- col_include
For a continuous col variable, any values that the limits should encompass (e.g. 0).
- col_labels
A function that takes the breaks as inputs (e.g. scales::label_comma()), or a vector of labels.
- col_legend_place
The place for the legend. Either "bottom", "right", "top" or "left". Or just the first letter of each.
- col_legend_ncol
The number of columns for the legend elements.
- col_legend_nrow
The number of rows for the legend elements.
- col_legend_rev
Reverse the elements of the legend. Defaults to FALSE.
- col_limits
A vector to determine the limits of the colour scale.
- col_oob
For a continuous col variable, a scales::oob_* function of how to handle values outside of limits (e.g. scales::oob_keep). Defaults to scales::oob_keep.
- col_rescale
For a continuous col variable, a scales::rescale function.
- col_scale
TRUE or FALSE of whether to add a col scale or not.
- col_title
Legend title string. Use "" for no title.
- col_trans
For a numeric col variable, a transformation object (e.g. "log10", "sqrt" or "reverse").
- facet_labels
A function that takes the breaks as inputs (e.g. scales::label_comma()), or a named vector of labels (e.g. c("value" = "label", ...)).
- facet_ncol
The number of columns of facets. Only applies to a facet layout of "wrap".
- facet_nrow
The number of rows of facets. Only applies to a facet layout of "wrap".
- facet_scales
Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".
- facet_space
Whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed". Only applies where the facet layout is "grid" and facet scales are not "fixed".
- facet_layout
Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".
- facet_switch
Whether the facet layout is "grid", whether to switch the facet labels to the opposite side of the plot. Either "x", "y" or "both".
- linetype_title
Legend title string. Use "" for no title.
- shape_title
Legend title string. Use "" for no title.
- size_title
Legend title string. Use "" for no title.
- caption
Caption title string.
- titles
A function to format unspecified titles. Defaults to snakecase::to_sentence_case.
- theme
A ggplot2 theme.
Examples
library(dplyr)
library(palmerpenguins)
penguins |>
gg_blank(
x = flipper_length_mm,
y = body_mass_g,
col = sex,
facet = species,
col_labels = stringr::str_to_sentence,
pal = c("#1B9E77", "#9E361B")
)