Skip to contents

scale_pattern_linewidth() scales the width of lines (e.g. the stripes of the "stripe" pattern). It is the pattern analogue of ggplot2::scale_linewidth(). The pattern_linewidth aesthetic supersedes using pattern_size for line widths (if pattern_linewidth is unset it falls back to pattern_size). Use scale_pattern_size() for the fontsize of the "text" pattern.

Usage

scale_pattern_linewidth_continuous(
  name = waiver(),
  breaks = waiver(),
  labels = waiver(),
  limits = NULL,
  range = c(1, 6),
  guide = "legend",
  ...,
  transform = "identity"
)

scale_pattern_linewidth(
  name = waiver(),
  breaks = waiver(),
  labels = waiver(),
  limits = NULL,
  range = c(1, 6),
  guide = "legend",
  ...,
  transform = "identity"
)

Arguments

name, breaks, labels, limits, guide, ..., transform

See ggplot2::scale_linewidth() for more information

range

a numeric vector of length 2 that specifies the minimum and maximum line width after transformation.

Value

A ggplot2::Scale object.

Examples

  if (require("ggplot2")) {
    # 'circle' pattern example
    df <- data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1))
    gg <- ggplot(df) +
      geom_col_pattern(
        aes(level, outcome, pattern_fill = level,
            linewidth = outcome, pattern_linewidth = outcome),
        pattern_density = 0.4,
        pattern_spacing = 0.3,
        pattern = 'circle',
        fill    = 'white',
        colour  = 'black'
      ) +
      theme_bw(18) +
      theme(legend.position = 'none') +
      scale_pattern_linewidth() +
      labs(
        title    = "ggpattern::geom_col_pattern()",
        subtitle = "pattern = 'circle'"
      )
    plot(gg)
  }