thomasp85 / ggraph

Grammar of Graph Graphics

Home Page:https://ggraph.data-imaginist.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deprecation warning for size aesthetic thrown by geom_edge_link (and similar) since ggplot2 version 3.4.0

david-barnett opened this issue · comments

Hi Thomas,

Since ggplot2 3.4.0 most ggraph edge geoms show deprecation warnings relating to use of the size aesthetic

Probably you are aware of this problem, but I didn't see a related issue, so I added a reprex below

thanks for your work on ggraph and ggplot2 (and everything else too!) :)

packageVersion("ggraph")
#> [1] '2.1.0'

library(ggraph)
#> Loading required package: ggplot2
library(tidygraph)
#> 
#> Attaching package: 'tidygraph'
#> The following object is masked from 'package:stats':
#> 
#>     filter

graph <- as_tbl_graph(highschool)
p <- ggraph(graph, layout = "kk") + geom_edge_link()
p
#> Warning: Using the `size` aesthetic in this geom was deprecated in ggplot2 3.4.0.
#> ℹ Please use `linewidth` in the `default_aes` field and elsewhere instead.

options(lifecycle_verbosity = "error")
p
#> Error in `geom_edge_link()`:
#> ! Problem while setting up geom aesthetics.
#> ℹ Error occurred in the 1st layer.
#> Caused by error:
#> ! Using the `size` aesthetic in this geom was deprecated in ggplot2
#>   3.4.0.
#> ℹ Please use `linewidth` in the `default_aes` field and elsewhere instead.

#> Backtrace:
#>      ▆
#>   1. ├─base::tryCatch(...)
#>   2. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#>   3. │   ├─base (local) tryCatchOne(...)
#>   4. │   │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#>   5. │   └─base (local) tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
#>   6. │     └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>   7. │       └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#>   8. ├─base::withCallingHandlers(...)
#>   9. ├─base::saveRDS(...)
#>  10. ├─base::do.call(...)
#>  11. ├─base (local) `<fn>`(...)
#>  12. └─global `<fn>`(input = base::quote("sappy-tern_reprex.R"))
#>  13.   └─rmarkdown::render(input, quiet = TRUE, envir = globalenv(), encoding = "UTF-8")
#>  14.     └─knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
#>  15.       └─knitr:::process_file(text, output)
#>  16.         ├─base::withCallingHandlers(...)
#>  17.         ├─knitr:::process_group(group)
#>  18.         └─knitr:::process_group.block(group)
#>  19.           └─knitr:::call_block(x)
#>  20.             └─knitr:::block_exec(params)
#>  21.               └─knitr:::eng_r(options)
#>  22.                 ├─knitr:::in_input_dir(...)
#>  23.                 │ └─knitr:::in_dir(input_dir(), expr)
#>  24.                 └─knitr (local) evaluate(...)
#>  25.                   └─evaluate::evaluate(...)
#>  26.                     └─evaluate:::evaluate_call(...)
#>  27.                       ├─evaluate (local) handle(...)
#>  28.                       │ └─base::try(f, silent = TRUE)
#>  29.                       │   └─base::tryCatch(...)
#>  30.                       │     └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#>  31.                       │       └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>  32.                       │         └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#>  33.                       ├─base::withCallingHandlers(...)
#>  34.                       ├─base::withVisible(value_fun(ev$value, ev$visible))
#>  35.                       └─knitr (local) value_fun(ev$value, ev$visible)
#>  36.                         └─knitr (local) fun(x, options = options)
#>  37.                           ├─base::withVisible(knit_print(x, ...))
#>  38.                           ├─knitr::knit_print(x, ...)
#>  39.                           └─knitr:::knit_print.default(x, ...)
#>  40.                             └─evaluate (local) normal_print(x)
#>  41.                               ├─base::print(x)
#>  42.                               └─ggplot2:::print.ggplot(x)
#>  43.                                 ├─ggplot2::ggplot_build(x)
#>  44.                                 ├─ggraph:::ggplot_build.ggraph(x)
#>  45.                                 ├─base::NextMethod()
#>  46.                                 └─ggplot2:::ggplot_build.ggplot(x)
#>  47.                                   └─ggplot2:::by_layer(...)
#>  48.                                     ├─rlang::try_fetch(...)
#>  49.                                     │ ├─base::tryCatch(...)
#>  50.                                     │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#>  51.                                     │ │   └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>  52.                                     │ │     └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#>  53.                                     │ └─base::withCallingHandlers(...)
#>  54.                                     └─ggplot2 (local) f(l = layers[[i]], d = data[[i]])
#>  55.                                       └─l$compute_geom_2(d)
#>  56.                                         └─ggplot2 (local) compute_geom_2(..., self = self)
#>  57.                                           └─self$geom$use_defaults(data, self$aes_params, modifiers)
#>  58.                                             └─ggplot2 (local) use_defaults(..., self = self)
#>  59.                                               └─ggplot2:::deprecate_soft0(...)
#>  60.                                                 └─lifecycle::deprecate_soft(..., user_env = user_env)
#>  61.                                                   └─lifecycle:::deprecate_stop0(msg)
#>  62.                                                     └─rlang::cnd_signal(...)

Created on 2022-11-12 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.1 (2022-06-23)
#>  os       macOS Big Sur ... 10.16
#>  system   x86_64, darwin17.0
#>  ui       X11
#>  language (EN)
#>  collate  en_GB.UTF-8
#>  ctype    en_GB.UTF-8
#>  tz       Europe/Amsterdam
#>  date     2022-11-12
#>  pandoc   2.18 @ /Applications/RStudio.app/Contents/MacOS/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version  date (UTC) lib source
#>  assertthat     0.2.1    2019-03-21 [1] CRAN (R 4.2.0)
#>  cli            3.4.1    2022-09-23 [1] CRAN (R 4.2.0)
#>  colorspace     2.0-3    2022-02-21 [1] CRAN (R 4.2.0)
#>  curl           4.3.3    2022-10-06 [1] CRAN (R 4.2.0)
#>  DBI            1.1.3    2022-06-18 [1] CRAN (R 4.2.0)
#>  digest         0.6.30   2022-10-18 [1] CRAN (R 4.2.1)
#>  dplyr          1.0.10   2022-09-01 [1] CRAN (R 4.2.0)
#>  evaluate       0.18     2022-11-07 [1] CRAN (R 4.2.0)
#>  fansi          1.0.3    2022-03-24 [1] CRAN (R 4.2.0)
#>  farver         2.1.1    2022-07-06 [1] CRAN (R 4.2.0)
#>  fastmap        1.1.0    2021-01-25 [1] RSPM (R 4.2.0)
#>  fs             1.5.2    2021-12-08 [1] RSPM (R 4.2.0)
#>  generics       0.1.3    2022-07-05 [1] CRAN (R 4.2.0)
#>  ggforce        0.4.1    2022-10-04 [1] CRAN (R 4.2.0)
#>  ggplot2      * 3.4.0    2022-11-04 [1] CRAN (R 4.2.1)
#>  ggraph       * 2.1.0    2022-10-09 [1] CRAN (R 4.2.0)
#>  ggrepel        0.9.2    2022-11-06 [1] CRAN (R 4.2.0)
#>  glue           1.6.2    2022-02-24 [1] CRAN (R 4.2.0)
#>  graphlayouts   0.8.3    2022-10-20 [1] CRAN (R 4.2.0)
#>  gridExtra      2.3      2017-09-09 [1] RSPM (R 4.2.0)
#>  gtable         0.3.1    2022-09-01 [1] CRAN (R 4.2.0)
#>  highr          0.9      2021-04-16 [1] RSPM (R 4.2.0)
#>  htmltools      0.5.3    2022-07-18 [1] CRAN (R 4.2.0)
#>  httr           1.4.4    2022-08-17 [1] CRAN (R 4.2.0)
#>  igraph         1.3.5    2022-09-22 [1] CRAN (R 4.2.0)
#>  knitr          1.40     2022-08-24 [1] CRAN (R 4.2.0)
#>  labeling       0.4.2    2020-10-20 [1] CRAN (R 4.2.0)
#>  lifecycle      1.0.3    2022-10-07 [1] CRAN (R 4.2.0)
#>  magrittr       2.0.3    2022-03-30 [1] CRAN (R 4.2.0)
#>  MASS           7.3-58.1 2022-08-03 [1] CRAN (R 4.2.0)
#>  mime           0.12     2021-09-28 [1] RSPM (R 4.2.0)
#>  munsell        0.5.0    2018-06-12 [1] CRAN (R 4.2.0)
#>  pillar         1.8.1    2022-08-19 [1] CRAN (R 4.2.0)
#>  pkgconfig      2.0.3    2019-09-22 [1] CRAN (R 4.2.0)
#>  polyclip       1.10-4   2022-10-20 [1] CRAN (R 4.2.0)
#>  purrr          0.3.5    2022-10-06 [1] CRAN (R 4.2.0)
#>  R.cache        0.16.0   2022-07-21 [1] CRAN (R 4.2.0)
#>  R.methodsS3    1.8.2    2022-06-13 [1] CRAN (R 4.2.0)
#>  R.oo           1.25.0   2022-06-12 [1] CRAN (R 4.2.0)
#>  R.utils        2.12.2   2022-11-11 [1] CRAN (R 4.2.1)
#>  R6             2.5.1    2021-08-19 [1] CRAN (R 4.2.0)
#>  Rcpp           1.0.9    2022-07-08 [1] CRAN (R 4.2.0)
#>  reprex         2.0.2    2022-08-17 [1] CRAN (R 4.2.0)
#>  rlang          1.0.6    2022-09-24 [1] CRAN (R 4.2.0)
#>  rmarkdown      2.18     2022-11-09 [1] CRAN (R 4.2.1)
#>  rstudioapi     0.14     2022-08-22 [1] CRAN (R 4.2.0)
#>  scales         1.2.1    2022-08-20 [1] CRAN (R 4.2.0)
#>  sessioninfo    1.2.2    2021-12-06 [1] RSPM (R 4.2.0)
#>  stringi        1.7.8    2022-07-11 [1] CRAN (R 4.2.0)
#>  stringr        1.4.1    2022-08-20 [1] CRAN (R 4.2.0)
#>  styler         1.8.1    2022-11-07 [1] CRAN (R 4.2.0)
#>  tibble         3.1.8    2022-07-22 [1] CRAN (R 4.2.0)
#>  tidygraph    * 1.2.2    2022-08-22 [1] CRAN (R 4.2.0)
#>  tidyr          1.2.1    2022-09-08 [1] CRAN (R 4.2.0)
#>  tidyselect     1.2.0    2022-10-10 [1] CRAN (R 4.2.0)
#>  tweenr         2.0.2    2022-09-06 [1] CRAN (R 4.2.0)
#>  utf8           1.2.2    2021-07-24 [1] CRAN (R 4.2.0)
#>  vctrs          0.5.0    2022-10-22 [1] CRAN (R 4.2.0)
#>  viridis        0.6.2    2021-10-13 [1] RSPM (R 4.2.0)
#>  viridisLite    0.4.1    2022-08-22 [1] CRAN (R 4.2.0)
#>  withr          2.5.0    2022-03-03 [1] CRAN (R 4.2.0)
#>  xfun           0.34     2022-10-18 [1] CRAN (R 4.2.0)
#>  xml2           1.3.3    2021-11-30 [1] RSPM (R 4.2.0)
#>  yaml           2.3.6    2022-10-18 [1] CRAN (R 4.2.1)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.2/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Separately but relatedly: While scale_edge_size_*() exist, scale_edge_linewidth_*() do not.

@RoyalTS there is (and have always been) scale_edge_width() which is kept as is (i.e. I will not change it to edge_linewidth)

All instances of bad size use should have been removed from ggraph now, but there remains some issues inherited from ggforce... That needs to be fixed there