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

Artefact when multiple points at the same location #36

Open
dicorynia opened this issue Mar 1, 2023 · 1 comment
Open

Artefact when multiple points at the same location #36

dicorynia opened this issue Mar 1, 2023 · 1 comment

Comments

@dicorynia
Copy link

dicorynia commented Mar 1, 2023

When several points share the same location, the plot merges all their data.

library(scatterpie)

df <- data.frame(id = c(1, 2),
                 lat = c(1.5, 1.5),
                 long = c(2.1, 2.1),
                 A = c(0.5, 0.15),
                 B = c(0.4, 0.15),
                 C = c(0.1, 0.2))
df$tot <- rowSums(df[, c("A", "B", "C")])

ggplot()+
  geom_scatterpie(data=df,
                  aes(x=long, y=lat, r = tot, group = id),
                  alpha = 0.5,
                  cols = c("A","B","C"))+
  coord_equal()

Expected :

image

A workaround would be to move a little their coordinates. It should be done anyway most of the time for legibility reasons...

Created on 2023-03-01 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value
#>  version  R version 4.1.1 (2021-08-10)
#>  os       Windows 10 x64 (build 19044)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  French_France.1252
#>  ctype    French_France.1252
#>  tz       Europe/Paris
#>  date     2023-03-01
#>  pandoc   2.19.2 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version date (UTC) lib source
#>  assertthat    0.2.1   2019-03-21 [1] CRAN (R 4.1.0)
#>  cli           3.5.0   2022-12-20 [1] CRAN (R 4.1.3)
#>  colorspace    2.0-3   2022-02-21 [1] CRAN (R 4.1.3)
#>  curl          4.3.3   2022-10-06 [1] CRAN (R 4.1.3)
#>  DBI           1.1.3   2022-06-18 [1] CRAN (R 4.1.3)
#>  digest        0.6.31  2022-12-11 [1] CRAN (R 4.1.3)
#>  dplyr         1.0.10  2022-09-01 [1] CRAN (R 4.1.3)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.1.0)
#>  evaluate      0.19    2022-12-13 [1] CRAN (R 4.1.3)
#>  fansi         1.0.3   2022-03-24 [1] CRAN (R 4.1.3)
#>  farver        2.1.1   2022-07-06 [1] CRAN (R 4.1.3)
#>  fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.1.0)
#>  fs            1.5.2   2021-12-08 [1] CRAN (R 4.1.3)
#>  generics      0.1.3   2022-07-05 [1] CRAN (R 4.1.3)
#>  ggforce       0.4.1   2022-10-04 [1] CRAN (R 4.1.3)
#>  ggfun         0.0.9   2022-11-21 [1] CRAN (R 4.1.3)
#>  ggplot2     * 3.4.0   2022-11-04 [1] CRAN (R 4.1.1)
#>  glue          1.6.2   2022-02-24 [1] CRAN (R 4.1.3)
#>  gtable        0.3.1   2022-09-01 [1] CRAN (R 4.1.3)
#>  highr         0.10    2022-12-22 [1] CRAN (R 4.1.3)
#>  htmltools     0.5.4   2022-12-07 [1] CRAN (R 4.1.3)
#>  httr          1.4.4   2022-08-17 [1] CRAN (R 4.1.3)
#>  knitr         1.41    2022-11-18 [1] CRAN (R 4.1.3)
#>  labeling      0.4.2   2020-10-20 [1] CRAN (R 4.1.0)
#>  lifecycle     1.0.3   2022-10-07 [1] CRAN (R 4.1.3)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.1.3)
#>  MASS          7.3-54  2021-05-03 [2] CRAN (R 4.1.1)
#>  mime          0.12    2021-09-28 [1] CRAN (R 4.1.1)
#>  munsell       0.5.0   2018-06-12 [1] CRAN (R 4.1.0)
#>  pillar        1.8.1   2022-08-19 [1] CRAN (R 4.1.3)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.1.0)
#>  polyclip      1.10-4  2022-10-20 [1] CRAN (R 4.1.3)
#>  purrr         1.0.0   2022-12-20 [1] CRAN (R 4.1.3)
#>  R.cache       0.16.0  2022-07-21 [1] CRAN (R 4.1.3)
#>  R.methodsS3   1.8.2   2022-06-13 [1] CRAN (R 4.1.3)
#>  R.oo          1.25.0  2022-06-12 [1] CRAN (R 4.1.3)
#>  R.utils       2.12.2  2022-11-11 [1] CRAN (R 4.1.3)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.1.1)
#>  Rcpp          1.0.9   2022-07-08 [1] CRAN (R 4.1.3)
#>  reprex        2.0.2   2022-08-17 [1] CRAN (R 4.1.3)
#>  rlang         1.0.6   2022-09-24 [1] CRAN (R 4.1.3)
#>  rmarkdown     2.19    2022-12-15 [1] CRAN (R 4.1.3)
#>  rstudioapi    0.14    2022-08-22 [1] CRAN (R 4.1.3)
#>  scales        1.2.1   2022-08-20 [1] CRAN (R 4.1.3)
#>  scatterpie  * 0.1.8   2022-09-03 [1] CRAN (R 4.1.3)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.1.2)
#>  stringi       1.7.6   2021-11-29 [1] CRAN (R 4.1.2)
#>  stringr       1.5.0   2022-12-02 [1] CRAN (R 4.1.3)
#>  styler        1.8.1   2022-11-07 [1] CRAN (R 4.1.3)
#>  tibble        3.1.8   2022-07-22 [1] CRAN (R 4.1.3)
#>  tidyr         1.2.1   2022-09-08 [1] CRAN (R 4.1.3)
#>  tidyselect    1.2.0   2022-10-10 [1] CRAN (R 4.1.3)
#>  tweenr        2.0.2   2022-09-06 [1] CRAN (R 4.1.3)
#>  utf8          1.2.2   2021-07-24 [1] CRAN (R 4.1.0)
#>  vctrs         0.5.1   2022-11-16 [1] CRAN (R 4.1.3)
#>  withr         2.5.0   2022-03-03 [1] CRAN (R 4.1.3)
#>  xfun          0.36    2022-12-21 [1] CRAN (R 4.1.3)
#>  xml2          1.3.3   2021-11-30 [1] CRAN (R 4.1.2)
#>  yaml          2.3.6   2022-10-18 [1] CRAN (R 4.1.3)
#> 
#>  [1] C:/Users/xxxx/Documents/R/win-library/4.1
#>  [2] C:/Program Files/R/R-4.1.1/library
#> 
#> ------------------------------------------------------------------------------
@dicorynia dicorynia changed the title Artefact when multiple point at the same location Artefact when multiple points at the same location Mar 1, 2023
@GuangchuangYu
Copy link
Member

@xiangpin this should be a bug when converting from wide to long data frame.

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

2 participants