-
Notifications
You must be signed in to change notification settings - Fork 125
Closed
Description
devtools::load_all()
library(ggplot2)
origin_data <- NLD_prov %>%
st_set_geometry(NULL) %>%
dplyr::mutate(FID = factor(dplyr::row_number())) %>%
dplyr::select(FID, origin_native, origin_west, origin_non_west) %>%
tidyr::pivot_longer(
cols = c(origin_native, origin_west, origin_non_west),
names_to = "origin",
values_to = "perc",
names_transform = as.factor
) %>%
dplyr::arrange(origin, FID) %>%
as.data.frame()
origin_cols <- get_brewer_pal("Dark2", 3)
grobs <- lapply(split(origin_data, origin_data$FID), function(x) {
ggplot2::ggplotGrob(ggplot(x, aes(x = "", y = -perc, fill = origin)) +
geom_bar(width = 1, stat = "identity") +
scale_y_continuous(expand = c(0, 0)) +
scale_fill_manual(values = origin_cols) +
theme_ps(plot.axes = FALSE))
})
grobs2 <- grobs
grobs2[[6]] <- 21
names(grobs2) <- as.character(NLD_prov$name)
tm_shape(NLD_prov) +
tm_polygons(group = "Provinces") +
tm_symbols(
shape = "name",
fill = "red",
col = "blue",
size = "population",
size.scale = tm_scale_continuous(values.scale = 4),
shape.scale = tm_scale_categorical(values = grobs2),
shape.legend = tm_legend_hide()
)
#> Error in grid.Call.graphics(C_setviewport, vp, TRUE) :
#> position and / or viewport infinite
Can reproduce interactively
Metadata
Metadata
Assignees
Labels
No labels