Bubble sizes out of order, when using a formula for the `color`/`name` attributes
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- r
- Domaine
- data-visualization
Piste de recherche
Aucun fichier source ni test n'est nommé. Commencez par exécuter les exemples plot_ly fournis avec des valeurs de couleur formula et statiques, puis suivez la manière dont les données de marker size, color et name sont assemblées. Le travail est considéré comme terminé lorsque les tailles des bulles restent alignées sur les lignes d'origine pour les seuils et les cas de name signalés, avec une couverture de régression pour les exemples.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Hi folks, I'm seeing a strange effect on scatter plot marker sizes, when using a formula for the color (and name) attributes.
(edited to add more test cases)
library(plotly)
#> Loading required package: ggplot2
#>
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#>
#> last_plot
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following object is masked from 'package:graphics':
#>
#> layout
df <- data.frame(x = c(1, 2, 3, 4, 5),
y = c(1, 2, 3, 4, 5),
z = c(1, 2, 3, 4, 5))
# Expected output: marker sizes in order
plot_ly(df,
x = ~x,
y = ~y,
type = "scatter",
mode = "markers",
marker = list(size = ~z,
sizeref = 0.1),
color = ~z < 2,
colors = c(I("green"), I("red")),
text = ~paste0("z: ", z))

# df has correct data
df
#> x y z
#> 1 1 1 1
#> 2 2 2 2
#> 3 3 3 3
#> 4 4 4 4
#> 5 5 5 5
# Buggy output: changing "color" formula threshold puts marker sizes out of order
plot_ly(df,
x = ~x,
y = ~y,
type = "scatter",
mode = "markers",
marker = list(size = ~z,
sizeref = 0.1),
color = ~z < 3,
colors = c(I("green"), I("red")),
text = ~paste0("z: ", z))

# df still has correct data
df
#> x y z
#> 1 1 1 1
#> 2 2 2 2
#> 3 3 3 3
#> 4 4 4 4
#> 5 5 5 5
# Buggy output: static vector also puts marker sizes out of order
plot_ly(df,
x = ~x,
y = ~y,
type = "scatter",
mode = "markers",
marker = list(size = ~z,
sizeref = 0.1),
color = c(TRUE, TRUE, FALSE, FALSE, FALSE),
colors = c(I("green"), I("red")),
text = ~paste0("z: ", z))

# Buggy output: use ifelse with (TRUE, FALSE)
plot_ly(df,
x = ~x,
y = ~y,
type = "scatter",
mode = "markers",
marker = list(size = ~z,
sizeref = 0.1),
color = ~ifelse(z < 3, TRUE, FALSE),
colors = c(I("green"), I("red")),
text = ~paste0("z: ", z))

# Possible workaround: use ifelse with (1, 0)
plot_ly(df,
x = ~x,
y = ~y,
type = "scatter",
mode = "markers",
marker = list(size = ~z,
sizeref = 0.1),
color = ~ifelse(z < 3, 1, 0),
colors = c(I("green"), I("red")),
text = ~paste0("z: ", z))

# Buggy again when adding "name" field with formula
plot_ly(df,
x = ~x,
y = ~y,
type = "scatter",
mode = "markers",
marker = list(size = ~z,
sizeref = 0.1),
color = ~ifelse(z < 3, 1, 0),
colors = c(I("green"), I("red")),
name = ~ifelse(z < 3, "Red", "Green"),
text = ~paste0("z: ", z))

Created on 2024-04-06 with reprex v2.1.0
Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.3.3 (2024-02-29)
#> os Ubuntu 22.04.4 LTS
#> system x86_64, linux-gnu
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/Indiana/Vevay
#> date 2024-04-06
#> pandoc 3.1.1 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> callr 3.7.5 2024-02-19 [1] CRAN (R 4.3.2)
#> cli 3.6.2 2023-12-11 [1] CRAN (R 4.3.2)
#> colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.3.0)
#> crosstalk 1.2.1 2023-11-23 [1] CRAN (R 4.3.2)
#> curl 5.2.0 2023-12-08 [1] CRAN (R 4.3.2)
#> data.table 1.15.0 2024-01-30 [1] CRAN (R 4.3.2)
#> digest 0.6.34 2024-01-11 [1] CRAN (R 4.3.2)
#> dplyr 1.1.4 2023-11-17 [1] CRAN (R 4.3.2)
#> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.3.0)
#> evaluate 0.23 2023-11-01 [1] CRAN (R 4.3.2)
#> fansi 1.0.6 2023-12-08 [1] CRAN (R 4.3.2)
#> farver 2.1.1 2022-07-06 [1] CRAN (R 4.3.0)
#> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.0)
#> fs 1.6.3 2023-07-20 [1] CRAN (R 4.3.2)
#> generics 0.1.3 2022-07-05 [1] CRAN (R 4.3.0)
#> ggplot2 * 3.5.0 2024-02-23 [1] CRAN (R 4.3.2)
#> glue 1.7.0 2024-01-09 [1] CRAN (R 4.3.2)
#> gtable 0.3.4 2023-08-21 [1] CRAN (R 4.3.2)
#> highr 0.10 2022-12-22 [1] CRAN (R 4.3.0)
#> htmltools 0.5.7 2023-11-03 [1] CRAN (R 4.3.2)
#> htmlwidgets 1.6.4 2023-12-06 [1] CRAN (R 4.3.2)
#> httr 1.4.7 2023-08-15 [1] CRAN (R 4.3.2)
#> jsonlite 1.8.8 2023-12-04 [1] CRAN (R 4.3.2)
#> knitr 1.45 2023-10-30 [1] CRAN (R 4.3.2)
#> lazyeval 0.2.2 2019-03-15 [1] CRAN (R 4.3.0)
#> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.3.2)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.0)
#> munsell 0.5.0 2018-06-12 [1] CRAN (R 4.3.0)
#> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.0)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.0)
#> plotly * 4.10.4 2024-01-13 [1] CRAN (R 4.3.2)
#> processx 3.8.3 2023-12-10 [1] CRAN (R 4.3.2)
#> ps 1.7.6 2024-01-18 [1] CRAN (R 4.3.2)
#> purrr 1.0.2 2023-08-10 [1] CRAN (R 4.3.2)
#> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.3.1)
#> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.3.1)
#> R.oo 1.26.0 2024-01-24 [1] CRAN (R 4.3.2)
#> R.utils 2.12.3 2023-11-18 [1] CRAN (R 4.3.2)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.0)
#> reprex 2.1.0 2024-01-11 [1] CRAN (R 4.3.3)
#> rlang 1.1.3 2024-01-10 [1] CRAN (R 4.3.2)
#> rmarkdown 2.25 2023-09-18 [1] CRAN (R 4.3.2)
#> rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.3.2)
#> scales 1.3.0 2023-11-28 [1] CRAN (R 4.3.2)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.0)
#> styler 1.10.2 2023-08-29 [1] CRAN (R 4.3.1)
#> tibble 3.2.1 2023-03-20 [1] CRAN (R 4.3.0)
#> tidyr 1.3.1 2024-01-24 [1] CRAN (R 4.3.2)
#> tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.3.0)
#> utf8 1.2.4 2023-10-22 [1] CRAN (R 4.3.2)
#> vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.3.2)
#> viridisLite 0.4.2 2023-05-02 [1] CRAN (R 4.3.0)
#> webshot 0.5.5 2023-06-26 [1] CRAN (R 4.3.2)
#> withr 3.0.0 2024-01-16 [1] CRAN (R 4.3.2)
#> xfun 0.42 2024-02-08 [1] CRAN (R 4.3.2)
#> xml2 1.3.6 2023-12-04 [1] CRAN (R 4.3.2)
#> yaml 2.3.8 2023-12-11 [1] CRAN (R 4.3.2)
#>
#> [1] /home/jonathan/R/x86_64-pc-linux-gnu-library/4.3
#> [2] /usr/local/lib/R/site-library
#> [3] /usr/lib/R/site-library
#> [4] /usr/lib/R/library
#>
#> ──────────────────────────────────────────────────────────────────────────────
Bad color formulas are:
z < 3z < 4z < 5
The results from z < 2 may also be incorrect ... they're just indiscernible given my example.
This behavior causes significant skewing/confusion for bubble plots of any size.
Thanks for reading!
- Langage dominant
- R
- Étoiles
- 2.7k
- Forks
- 641
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de plotly/plotly.R
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
-
Data gets dropped in add_trace and consequently points have the wrong color if NA is present Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 72/100
-
save_image Error Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 52/100
Toutes les issues de plotly/plotly.R
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
robjhyndman/forecast#1220 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
JamesHWade/deputy#192 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
bug triage_needed
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
pharmaverse/rtables#1123 · 1 commentaire ·