Skip to contents

based on coord_polar2(), but paths are connected linear. See the documentation of coord_polar2() for more Information and examples

Usage

coord_radar(theta = "x", start = 0, direction = 1, bg = NULL)

Arguments

theta

variable to map angle to (x or y)

start

Offset of starting point from 12 o'clock in radians. Offset is applied clockwise or anticlockwise depending on value of direction.

direction

1, clockwise; -1, anticlockwise

bg

raster for background image

Examples

library(ggplot2)
fn <- rOstluft.data::f("Zch_Stampfenbachstrasse_2010-2014.csv")
data <- rOstluft::read_airmo_csv(fn)
data <- rOstluft::rolf_to_openair(data)

funs <- list(
  "median",
  "mean",
  "q95" = ~ stats::quantile(., probs = 0.95)
)

data_summarized <- summary_wind(data, ws, wd, NOx, fun = funs,
  ws_cutfun = cut_number.fun(1)
)

# background map
bbox <- bbox_lv95(2683141, 1249040, 500)
bg <- get_stadia_map(bbox)
#>  © Stadia Maps © Stamen Design © OpenMapTiles © OpenStreetMap contributors.

radar <- ggplot(data_summarized, aes(x = wd, y = NOx, color = stat, group = stat)) +
  geom_polygon(size = 1, fill = NA) +
  scale_color_viridis_d(end = 0.6) +
  scale_y_continuous(limits = c(0, NA), expand = c(0,0, 0, 0))
#> Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
#>  Please use `linewidth` instead.

radar + coord_radar(start = - 22.5 / 180 * pi)


# add background map
radar + coord_radar(start = - 22.5 / 180 * pi, bg = bg)


# facets
radar + facet_wrap(vars(stat)) +
  coord_radar(start = - 22.5 / 180 * pi)