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
|
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 |
One of:
|
na.value |
The aesthetic value to use for missing ( |
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')