Custom palettes for two package datasets: mta_bus_lines and hmt_2017
(both for cluster and cluster group).
Usage
scale_mapbaltimore(
palette = NULL,
values = NULL,
na.value = "grey50",
aesthetics = c("color", "fill"),
error_call = caller_env(),
...
)
scale_color_mapbaltimore(palette = NULL, na.value = "grey50", ...)
scale_fill_mapbaltimore(palette = NULL, na.value = "grey50", ...)Arguments
- palette
Options include "mta_bus", "hmt_2017", "hmt_cluster", "cluster", "hmt_cluster_group", or "cluster_group", Default:
NULL- values
a set of aesthetic values to map data values to. The values will be matched in order (usually alphabetical) with the limits of the scale, or with
breaksif provided. If this is a named vector, then the values will be matched based on the names instead. Data values that don't match will be givenna.value.- na.value
Defaults to "grey50"
- aesthetics
Character string or vector of character strings listing the name(s) of the aesthetic(s) that this scale works with. This can be useful, for example, to apply colour settings to the
colourandfillaesthetics at the same time, viaaesthetics = c("colour", "fill").- error_call
The execution environment of a currently running function, e.g.
caller_env(). The function will be mentioned in error messages as the source of the error. See thecallargument ofabort()for more information.- ...
Arguments passed on to
discrete_scalepaletteA palette function that when called with a single integer argument (the number of levels in the scale) returns the values that they should take (e.g.,
scales::pal_hue()).limitsOne of:
NULLto use the default scale valuesA character vector that defines possible values of the scale and their order
A function that accepts the existing (automatic) values and returns new ones. Also accepts rlang lambda function notation.
dropShould unused factor levels be omitted from the scale? The default,
TRUE, uses the levels that appear in the data;FALSEuses all the levels in the factor.na.translateUnlike continuous scales, discrete scales can easily show missing values, and do so by default. If you want to remove missing values from a discrete scale, specify
na.translate = FALSE.scale_nameThe name of the scale that should be used for error messages associated with this scale.
nameThe name of the scale. Used as the axis or legend title. If
waiver(), the default, the name of the scale is taken from the first mapping used for that aesthetic. IfNULL, the legend title will be omitted.labelsOne of:
NULLfor no labelswaiver()for the default labels computed by the transformation objectA character vector giving labels (must be same length as
breaks)An expression vector (must be the same length as breaks). See ?plotmath for details.
A function that takes the breaks as input and returns labels as output. Also accepts rlang lambda function notation.
guideA function used to create a guide or its name. See
guides()for more information.callThe
callused to construct the scale for reporting messages.superThe super class to use for the constructed scale
Examples
if (FALSE) { # \dontrun{
if (interactive()) {
library(ggplot2)
ggplot(data = dplyr::filter(mta_bus_lines, frequent)) +
geom_sf(aes(color = route_abb), alpha = 0.5, size = 2) +
scale_mapbaltimore(palette = "bus") +
theme_minimal()
ggplot(data = hmt_2017) +
geom_sf(aes(fill = cluster_group, color = cluster_group)) +
scale_mapbaltimore(palette = "cluster_group") +
theme_minimal()
}
} # }
