plotly / plotly/plotly.R

Color group does not appear in the animated plotly

Offen
#1,805 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

I am trying to plot an animated frame with plotly. The goal is to plot how some units (id) changes in two continuous variables AND one categorical. The problem arises because the third category appears not from the beginning. In the plot, the units with “type3” category do not appear on the plot after 2001 and the ‘type3’ entry does not appear in the legend. The code shows an example of the data structure and problem. The same problem with boxplot - only two categories are present for all frames.

The ideal result is appearing of all 3 groups form the beginning. For scatterplot, points should change the color and for boxplot there should be an empty space from the beginning for the third category or it should appear after reaching the proper year.

df <- data.frame(x = rnorm(50), 
                 y = rnorm(50), 
                 year = c(rep(2000, 10), rep(2001, 10), rep(2002, 10), rep(2003, 10), rep(2004, 10)),
                 id = rep(1:10, 5),
                 model = c(rep('type1', 5), rep('type2', 5), rep('type1', 5) , rep('type2', 5),
                           rep('type1', 3), rep('type2', 2), rep('type3', 5) ,
                           rep('type1', 4), rep('type2', 5), rep('type3', 1) ,
                           rep('type1', 3), rep('type2', 2), rep('type3', 5) ))

cols <- c(
  "type1" = "#bc80bd",
  
  "type2" = "#fdb462", 
  "type3" = "#b3de69"
)



plot_ly(df,  x = ~x, 
        y= ~y, 
        color = ~model,
        text = ~id,
        frame = ~year,
        opacity = .8, 
        marker = list(size = 10),
        colors = cols,
        type = 'scatter')

plot_ly(df, 
        y= ~y, 
        color = ~model,
        frame = ~year,
        opacity = .8, 
        colors = cols,
        type = 'box')

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 damit, die bereitgestellten R-Beispiele für animierte Streu- und Boxplots auszuführen, und vergleiche anschließend die Kategorienlegende und die Traces über die Jahres-Frames hinweg. Das Issue ist behoben, wenn type3 von Anfang an konsistent behandelt wird, mit dem erwarteten Farb- und Legendenverhalten für Streudiagramme und einer definierten leeren oder verspäteten Darstellung für Boxplots.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
plotly, 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
42/100

Neue Issues direkt in Ihr Postfach

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