scale_mapbaltimore: Scales for Baltimore data

View source: R/scale_mapbaltimore.R

scale_mapbaltimoreR Documentation

Scales for Baltimore data

Description

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 breaks if 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 given na.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 colour and fill aesthetics at the same time, via aesthetics = 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 the call argument of abort() for more information.

...

Arguments passed on to discrete_scale

limits

One of:

  • NULL to use the default scale values

  • A 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.

drop

Should unused factor levels be omitted from the scale? The default, TRUE, uses the levels that appear in the data; FALSE includes the levels in the factor. Please note that to display every level in a legend, the layer should use show.legend = TRUE.

na.translate

Unlike 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.

name

The 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. If NULL, the legend title will be omitted.

labels

One of:

  • NULL for no labels

  • waiver() for the default labels computed by the transformation object

  • A 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.

guide

A function used to create a guide or its name. See guides() for more information.

call

The call used to construct the scale for reporting messages.

super

The super class to use for the constructed scale

Examples

## Not run: 
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()
}

## End(Not run)


elipousson/mapbaltimore documentation built on Nov. 11, 2024, 8:25 p.m.