R plotly boxplots overwriting with numerical labels
Nessuno ha ancora preso questa issue.
- Lingua principale
- R
- Stelle
- 2.7k
- Fork
- 641
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
R plotly boxplots overwriting with numerical labels
I've asked this question on SO here: https://stackoverflow.com/questions/76466189/r-plotly-boxplots-overwriting-with-numerical-labels, but I'm wondering if it's a bug with the latest versions of the plotly library in R
Plotting boxplots with numeric (or numeric-as-character) as x-variable results in boxplots a) not located in the correct locations and b) with boxes overplotted
library(plotly)
colors <- c("red","blue","green","pink","brown")
data.in <- data.frame(Age=25*rnorm(100)+50, IMD=sample(5,100,replace=TRUE))
fig <- plot_ly(data=data.in[data.in$IMD == "1",], y=~Age, type="box", color=I(colors[1]),name="1 - least")
fig <- fig %>% add_trace(data=data.in[data.in$IMD == "2",], y=~Age, type="box", color=I(colors[2]),name="2")
fig <- fig %>% add_trace(data=data.in[data.in$IMD == "3",], y=~Age, type="box", color=I(colors[3]),name="3")
fig <- fig %>% add_trace(data=data.in[data.in$IMD == "4",], y=~Age, type="box", color=I(colors[4]),name="4")
fig <- fig %>% add_trace(data=data.in[data.in$IMD == "5",], y=~Age, type="box", color=I(colors[5]),name="5 - most")
fig <- fig %>% layout(yaxis = list(title = "Age"),
xaxis = list(title = "IMD"),
boxgap = 0.1, boxgroupgap=0)
This results in a plot similar to
Specifying 'x=~' in each add_trace does place the boxes in the correct places so is a temporary workaround, but I think that this may be a bug with the package, as the above code with labels which don't start with numbers (in the 'name=' attribute) does give the correct placement:
library(plotly)
colors <- c("red","blue","green","pink","brown")
data.in <- data.frame(Age=25*rnorm(100)+50, IMD=sample(5,100,replace=TRUE))
fig <- plot_ly(data=data.in[data.in$IMD == "1",], y=~Age, type="box", color=I(colors[1]),name="A")
fig <- fig %>% add_trace(data=data.in[data.in$IMD == "2",], y=~Age, type="box", color=I(colors[2]),name="B")
fig <- fig %>% add_trace(data=data.in[data.in$IMD == "3",], y=~Age, type="box", color=I(colors[3]),name="C")
fig <- fig %>% add_trace(data=data.in[data.in$IMD == "4",], y=~Age, type="box", color=I(colors[4]),name="D")
fig <- fig %>% add_trace(data=data.in[data.in$IMD == "5",], y=~Age, type="box", color=I(colors[5]),name="E")
fig <- fig %>% layout(yaxis = list(title = "Age"),
xaxis = list(title = "IMD"),
boxgap = 0.1, boxgroupgap=0)
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con la riproduzione R fornita usando plot_ly(), add_trace() e layout(); confronta i nomi delle trace numerici e non numerici e il workaround esplicito x=. Il lavoro è completato quando le trace di boxplot con nomi numerici o numerici come caratteri occupano posizioni x distinte e previste senza richiedere valori x espliciti. Nell’issue non sono indicati file sorgente o test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- plotly, r
- Ambito
- data-visualization
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100