thomasp85 / ggforce

Accelerating ggplot2
https://ggforce.data-imaginist.com
Other
916 stars 105 forks source link

`geom_circle()` and `geom_ellipse()` do not handle `linewidth` aesthetic properly #287

Closed Darxor closed 7 months ago

Darxor commented 1 year ago

Since ggplot 3.4.0 size was replaced with linewidth, but it seems like geom_circle() and geom_ellipse() don't properly respect this change. As it ignores linewidth outside of aes() and raises lifecycle warning.

See code below

library(ggplot2)
library(ggforce)

ggplot() +
  geom_ellipse(
    aes(x0 = 0, y0 = 0, a = 10, b = 3, angle = 0),
    linewidth = 5
  ) +
  coord_fixed()
#> Warning in geom_ellipse(aes(x0 = 0, y0 = 0, a = 10, b = 3, angle = 0), linewidth
#> = 5): Ignoring unknown parameters: `linewidth`
#> 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.


ggplot() +
  geom_circle(
    aes(x0 = 0, y0 = 0, r = 10),
    linewidth = 5
  ) +
  coord_fixed()
#> Warning in geom_circle(aes(x0 = 0, y0 = 0, r = 10), linewidth = 5): Ignoring
#> unknown parameters: `linewidth`

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

It is, however, possible to control linewidth inside aes(), but it also raises warnings:

library(ggplot2)
library(ggforce)

ggplot() +
  geom_circle(
    aes(x0 = 0, y0 = 0, r = 10,
        linewidth = I(3)),
  ) +
  coord_fixed()
#> Warning in geom_circle(aes(x0 = 0, y0 = 0, r = 10, linewidth = I(3)), ):
#> Ignoring unknown aesthetics: linewidth
#> 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.

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

Session info ```r R version 4.2.2 (2022-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22621) Matrix products: default locale: [1] LC_COLLATE=Russian_Russia.utf8 LC_CTYPE=Russian_Russia.utf8 LC_MONETARY=Russian_Russia.utf8 LC_NUMERIC=C LC_TIME=Russian_Russia.utf8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] ggforce_0.4.1 ggplot2_3.4.0 loaded via a namespace (and not attached): [1] Rcpp_1.0.9 rstudioapi_0.14 magrittr_2.0.3 MASS_7.3-58.1 tidyselect_1.2.0 munsell_0.5.0 colorspace_2.0-3 R6_2.5.1 ragg_1.2.4 [10] rlang_1.0.6 fansi_1.0.3 dplyr_1.0.10 tools_4.2.2 grid_4.2.2 gtable_0.3.1 sessioninfo_1.2.2 utf8_1.2.2 cli_3.4.1 [19] DBI_1.1.3 withr_2.5.0 systemfonts_1.0.4 assertthat_0.2.1 tibble_3.1.8 lifecycle_1.0.3 crayon_1.5.2 textshaping_0.3.6 farver_2.1.1 [28] tweenr_2.0.2 vctrs_0.5.1 glue_1.6.2 labeling_0.4.2 polyclip_1.10-4 compiler_4.2.2 pillar_1.8.1 generics_0.1.3 scales_1.2.1 [37] pkgconfig_2.0.3 ```
Darxor commented 1 year ago

After some testing it appears that this problem exists also for:

Geoms I've tested, where `linewidth` works fine - geom_arc - geom_autodensity / geom_autohistogram - geom_segment - geom_bezier - geom_bspline - geom_diagonal - geom_parallel_sets - geom_regon - geom_shape - geom_spiro - geom_voronoi_segment - geom_delaunay_tile
hmlea commented 1 year ago

Any update or workaround on this? I have been having the same problem for a while as well.

thomasp85 commented 7 months ago

Fixed