R/functions.R
ggradar.Rd
Diagrammes en radar avancés pour ggplot2 (Enhanced Radar Plots for ggplot2)
ggradar(
plot.data,
base.size = 15,
font.radar = "sans",
values.radar = c("0%", "50%", "100%"),
axis.labels = colnames(plot.data)[-1],
grid.min = 0,
grid.mid = 0.5,
grid.max = 1,
centre.y = grid.min - ((1/9) * (grid.max - grid.min)),
plot.extent.x.sf = 1,
plot.extent.y.sf = 1.2,
x.centre.range = 0.02 * (grid.max - centre.y),
label.centre.y = FALSE,
grid.line.width = 0.5,
gridline.min.linetype = "longdash",
gridline.mid.linetype = "longdash",
gridline.max.linetype = "longdash",
gridline.min.colour = "grey",
gridline.mid.colour = "#007A87",
gridline.max.colour = "grey",
grid.label.size = 6,
gridline.label.offset = -0.1 * (grid.max - centre.y),
label.gridline.min = TRUE,
label.gridline.mid = TRUE,
label.gridline.max = TRUE,
axis.label.offset = 1.15,
axis.label.size = 5,
axis.line.colour = "grey",
group.line.width = 1.5,
group.point.size = 6,
group.colours = NULL,
background.circle.colour = "#D7D6D1",
background.circle.transparency = 0.2,
plot.legend = if (nrow(plot.data) > 1) TRUE else FALSE,
legend.title = "",
plot.title = "",
legend.text.size = 14,
legend.position = "left"
)
Most of the code is from https://rstudio-pubs-static.s3.amazonaws.com/5795_e6e6411731bb4f1b9cc7eb49499c2082.html.
dataframe comprising one row per group
text size
text font family
values to print at minimum, 'average', and maximum gridlines
names of axis labels if other than column names supplied via plot.data
value at which mininum grid line is plotted
value at which 'average' grid line is plotted
value at which maximum grid line is plotted
value of y at centre of plot
controls relative size of plot horizontally
controls relative size of plot vertically
controls axis label alignment
whether value of y at centre of plot should be labelled
width of gridline
line type of minimum gridline
line type of 'average' gridline
line type of maximum gridline
colour of minimum gridline
colour of 'average' gridline
colour of maximum gridline
text size of gridline label
displacement to left/right of central vertical axis
whether or not to label the mininum gridline
whether or not to label the 'mininum'average' gridline
whether or not to label the maximum gridline
vertical displacement of axis labels from maximum grid line, measured relative to circle diameter
text size of axis label
colour of axis line
line width of group
point size of group
colour of group
colour of background circle/radar
transparency of background circle/radar
whether to include a plot legend
title of legend
title of radar plot
text size in legend
position of legend, valid values are "top", "right", "bottom", "left"
a ggplot object
library(dplyr)
library(scales)
library(tibble)
mtcars_radar <- mtcars %>%
as_tibble(rownames = "group") %>%
mutate_at(vars(-group), rescale) %>%
tail(4) %>%
select(1:10)
mtcars_radar
#> # A tibble: 4 × 10
#> group mpg cyl disp hp drat wt qsec vs am
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Ford Pantera L 0.230 1 0.698 0.749 0.673 0.424 0 0 1
#> 2 Ferrari Dino 0.396 0.5 0.184 0.435 0.396 0.321 0.119 0 1
#> 3 Maserati Bora 0.196 1 0.573 1 0.359 0.526 0.0119 0 1
#> 4 Volvo 142E 0.468 0 0.124 0.201 0.622 0.324 0.488 1 1
ggradar(mtcars_radar)