Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example erroring on main #852

Closed
olivroy opened this issue Mar 28, 2024 · 1 comment
Closed

Example erroring on main #852

olivroy opened this issue Mar 28, 2024 · 1 comment

Comments

@olivroy
Copy link
Contributor

olivroy commented Mar 28, 2024

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
Copy link
Contributor Author

olivroy commented Apr 9, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant