plotly / plotly/plotly.R

subplot does not seem to handle well relatively long lists

Offen
#1,515 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

plotly.js
Vorherrschende Sprache
R
Sterne
2.7k
Forks
641
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Hi,

I'm trying to use subplot in order to vertically group bar plots, sharing their x-axis.

Here are example data which have 28 groups where I'm creating a bar plot over 4 families in each and then trying to vertically combine them using subplot:

set.seed(1)
df <- data.frame(group = paste0("G",unlist(lapply(1:28,function(i) rep(i,4)))),
                 family = paste0("F",rep(1:4,28)),
                 log2n = log2(as.integer(runif(4*28,0,30))+1),
                 stringsAsFactors = F)

Creating the list of bar plots:

library(plotly)
groups <- unique(df$group)
y.range <- c(0,max(df$log2n))
plot.list <- lapply(1:length(groups),function(g){
  group.df <- dplyr::filter(df,group == groups[g])
  plot_ly(x=group.df$family,y=group.df$log2n,type='bar',name=group.df$family,color=group.df$family,showlegend=(g==length(groups))) %>%
    layout(yaxis=list(range=y.range))
})

If I try:
p <- plotly::subplot(plot.list,shareX=T,nrows=length(plot.list))

Screen Shot 2019-04-10 at 6 48 53 PM

So it seems like some sort of an overflow.

I gradually cut down on the number of plots in plot.list that I run subplot on and when reach 19 it seemed to stop 'overflowing':
p <- plotly::subplot(plot.list[1:19],shareX=T,nrows=19)
Screen Shot 2019-04-10 at 6 50 37 PM

Any idea if there's hope to get all 28 bar plots without overflowing?

Thanks a lot

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem reproduzierbaren Aufruf von plotly::subplot unter Verwendung von 28 vertikal gestapelten Balkendiagrammen und vergleiche ihn dann mit dem Fall mit 19 Diagrammen, der nicht überläuft. Untersuche, wie subplot nrows und gemeinsam genutzte x-Achsen bei langen Plot-Listen behandelt; als abgeschlossen gilt, dass alle 28 Diagramme ohne Überlauf gerendert werden und die gemeinsame Achse und Legende erhalten bleiben.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
r
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.