based on coord_polar2()
, but paths are connected linear. See the documentation
of coord_polar2()
for more Information and examples
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)