scale_radius_discrete {PieGlyph}R Documentation

Scales for the pie glyph radius

Description

scale_radius_*() is useful for adjusting the radius of the pie glyphs.

Usage

scale_radius_discrete(..., range = c(0.25, 0.6), unit = "cm")

scale_radius_manual(..., values, unit = "cm", breaks = waiver(), na.value = NA)

scale_radius_continuous(..., range = c(0.25, 0.6), unit = "cm")

scale_radius(..., range = c(0.25, 0.6), unit = "cm")

Arguments

...

Arguments passed on to continuous_scale

minor_breaks

One of:

  • NULL for no minor breaks

  • waiver() for the default breaks (one minor break between each major break)

  • A numeric vector of positions

  • A function that given the limits returns a vector of minor breaks. Also accepts rlang lambda function notation. When the function has two arguments, it will be given the limits and major breaks.

oob

One of:

  • Function that handles limits outside of the scale limits (out of bounds). Also accepts rlang lambda function notation.

  • The default (scales::censor()) replaces out of bounds values with NA.

  • scales::squish() for squishing out of bounds values into range.

  • scales::squish_infinite() for squishing infinite values into range.

na.value

Missing values will be replaced with this value.

call

The call used to construct the scale for reporting messages.

super

The super class to use for the constructed scale

range

a numeric vector of length 2 that specifies the minimum and maximum size of the plotting symbol after transformation.

unit

Unit for the radius of the pie glyphs. Default is "cm", but other units like "in", "mm", etc. can be used.

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.

breaks

One of:

  • NULL for no breaks

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

  • A numeric vector of positions

  • A function that takes the limits as input and returns breaks as output (e.g., a function returned by scales::extended_breaks()). Note that for position scales, limits are provided after scale expansion. Also accepts rlang lambda function notation.

na.value

The aesthetic value to use for missing (NA) values

Value

A ggplot scale object adjusting the radii of the pie glyphs

Examples

## Load libraries
library(dplyr)
library(tidyr)
library(ggplot2)

## Simulate raw data
set.seed(789)
plot_data <- data.frame(y = rnorm(10, 100, 30),
                        x = 1:10,
                        group = sample(size = 10,
                                       x = c(1, 2, 3),
                                       replace = TRUE),
                        A = round(runif(10, 3, 9), 2),
                        B = round(runif(10, 1, 5), 2),
                        C = round(runif(10, 3, 7), 2),
                        D = round(runif(10, 1, 9), 2))

head(plot_data)

## Create plot
p <- ggplot(data = plot_data)+
    geom_pie_glyph(aes(x = x, y = y, radius = group),
                   slices = c('A', 'B', 'C', 'D'))+
    labs(y = 'Response', x = 'System',
         fill = 'Attributes')+
    theme_classic()

p + scale_radius_continuous(range = c(0.2, 0.5))

q <- ggplot(data = plot_data)+
    geom_pie_glyph(aes(x = x, y = y,
                       radius = as.factor(group)),
                   slices = c('A', 'B', 'C', 'D'))+
    labs(y = 'Response', x = 'System',
         fill = 'Attributes', radius = 'Group')+
    theme_classic()

q + scale_radius_discrete(range = c(0.05, 0.2), unit = 'in',
                          name = 'Group')

q + scale_radius_manual(values = c(2, 6, 4), unit = 'mm',
                        labels = paste0('G', 1:3), name = 'G')

[Package PieGlyph version 1.0.0 Index]