Categoryorder not working when specifying plot type
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
When using the category order parameter, no plot is generated if the plot type is specified in the plot_ly call:
p <- plotly::plot_ly(type = 'bar')
colNames <- names(iris)
colNames <- colNames[-which(colNames == 'Species')]
for(trace in colNames){
p <- p %>% plotly::add_trace(data= iris, x = ~ Species, y = as.formula(paste0("~`", trace, "`")), name = trace)
}
p %>% layout(xaxis = list(categoryorder='total descending'))
With the following warning, which I don't understand since I'm not combining discrete and non-discrete data in the same axis:
Warning message:
Can't display both discrete & non-discrete data on same axis
If I specify the type in add_trace instead of the plot, then it works correctly and the warning is gone:
p <- plotly::plot_ly()
colNames <- names(df)
colNames <- colNames[-which(colNames == 'Species')]
for(trace in colNames){
p <- p %>% plotly::add_trace(type = 'bar', data= iris, x = ~ Species, y = as.formula(paste0("~`", trace, "`")), name = trace)
}
p %>% layout(xaxis = list(categoryorder='total descending'))
Maybe this is the intended behavior? If so, why does specifying the type in the traces works and not in the plot? The warning seems unclear to me.
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 eseguendo la riproduzione R fornita con iris e confronta plot_ly(type = 'bar') con add_trace(type = 'bar'). Traccia il modo in cui plot_ly e add_trace propagano il type e il modo in cui layout(xaxis = list(categoryorder = 'total descending')) gestisce le trace risultanti. Il lavoro è completato quando la riproduzione non emette più l'avviso e l'ordinamento delle categorie funziona in modo coerente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- 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