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

geom_sf_label() returns an error #5877

Closed
kobetst opened this issue May 2, 2024 · 3 comments
Closed

geom_sf_label() returns an error #5877

kobetst opened this issue May 2, 2024 · 3 comments
Labels
reprex needs a minimal reproducible example

Comments

@kobetst
Copy link

kobetst commented May 2, 2024

Most probaly, the problem has occured after the last updates of ggplot2 package. I used ggplot2 almost daily, but the error started appearing just two days ago (in my case, within ggVennDiagram). A reproducible code with example data and the error is below. ggVennDiagram itself works fine, the problem is geom_sf_label(). Upgrade to R 4.4.0 and re-installation of ggplot2 (now ggplot2_3.5.1) didn't help.

reprex(input = "Example.R")

library(ggVennDiagram)
library(ggplot2)
x = list(A=1:5,B=2:7,C=3:6,D=4:9)
ggVennDiagram(x) +
geom_sf_label(mapping = aes(label = count), data = venn_region(process_data(Venn(x))))

#> Error in geom_sf_label():
#> ! Problem while computing aesthetics.
#> ℹ Error occurred in the 5th layer.
#> Caused by error in .data$X:
#> ! Column X not found in .data.

rlang::last_trace()
<error/rlang_error>
Error in geom_sf_label():
! Problem while computing aesthetics.
ℹ Error occurred in the 5th layer.
Caused by error in .data$X:
! Column X not found in .data.

Backtrace:

  1. ├─base (local) <fn>(x)
  2. ├─ggplot2:::print.ggplot(x)
  3. │ ├─ggplot2::ggplot_build(x)
  4. │ └─ggplot2:::ggplot_build.ggplot(x)
  5. │ └─ggplot2:::by_layer(...)
  6. │ ├─rlang::try_fetch(...)
  7. │ │ ├─base::tryCatch(...)
  8. │ │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
  9. │ │ │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
  10. │ │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
  11. │ │ └─base::withCallingHandlers(...)
  12. │ └─ggplot2 (local) f(l = layers[[i]], d = data[[i]])
  13. │ └─l$compute_aesthetics(d, plot)
  14. │ └─ggplot2 (local) compute_aesthetics(..., self = self)
  15. │ └─base::lapply(aesthetics, eval_tidy, data = data, env = env)
  16. │ └─rlang (local) FUN(X[[i]], ...)
  17. ├─X
  18. ├─rlang:::$.rlang_data_pronoun(.data, X)
  19. │ └─rlang:::data_pronoun_get(...)
  20. └─rlang:::abort_data_pronoun(x, call = y)
@teunbrand
Copy link
Collaborator

Hi there, thanks for the report. Can you give a minimal reproducible example using ggplot() and geom_sf_label()? In particular, can we eliminate ggVennDiagram() from this example, to make sure that the problem is with ggplot2 and not the ggVennDiagram package?

@teunbrand teunbrand added the reprex needs a minimal reproducible example label May 2, 2024
@kobetst
Copy link
Author

kobetst commented May 2, 2024

Hi, you were right, and the actual problem was ggVennDiagram (ggplot exapmle without ggVennDiagram, but with geom_sf_label(), was OK). I found out that ggVennDiagram package has been also substantially remastered just recently, and stopped accepting geom_sf_label() function... Today I found and tried their new tutorial and got normal venn plots, as before. So, thanks a lot for the fast reply and your time!

@teunbrand
Copy link
Collaborator

I'm not sure how applicable this is, but when imposing new layers on a pre-existing plot where you don't have control over aesthetics etc, it might be best to use inherit.aes = FALSE to not mix up the aesthetics.
As the problem appears to be related to ggVennDiagram, I think it is safe to close here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reprex needs a minimal reproducible example
Projects
None yet
Development

No branches or pull requests

2 participants