Example erroring on main
Closed this issue · 1 comments
olivroy commented
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
olivroy commented
Thanks for fixing.
In case you are not aware, this example errors. #860
devtools::load_all()
NLD_prov$x = seq(10, by = 5, length.out = 12)
tm_shape(NLD_prov) +
tm_symbols(size = "x", size.scale = tm_scale_continuous(values.scale = 4)) +
tm_text(
text = "x"
)
#> Erreur : Incorrect values for layer text, aesthetic text; values should conform visual variable "text".
Also, you can delete this line in R/tm_layers_cartogram.R to avoid docs note , I added a change that conflicts with yours Done in #859
#' @param type,itermax,expansion,inplace,share Additional options