Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

`colors` argument to `add_trace` is only respected if the trace type *isn't* specified in the `plot_ly` call

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

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
45/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
r

Rechercherichtung

Reproduziere die beiden plot_ly/add_trace-Beispiele mit iris und vergleiche die erzeugten Paletten. Verfolge die Farbverarbeitung durch die Einstiegspunkte plot_ly und add_trace, insbesondere den expliziten Pfad type="scatter". Als erledigt gilt die Aufgabe, wenn beide Aufrufformen colors="Blues" konsistent berücksichtigen und eine Regressionstestabdeckung für die unterschiedlichen Beispiele vorhanden ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

I'd expect these two lines of code to produce the same output, but only the first does what I expect (uses the colors argument to pick a palette for the points):

plot_ly(data = iris) %>%
  add_trace(x = ~Sepal.Length, y = ~Sepal.Width, color = ~Species, colors = "Blues", mode = "markers")
Image
plot_ly(data = iris, type="scatter") %>%
  add_trace(x = ~Sepal.Length, y = ~Sepal.Width, color = ~Species, colors = "Blues", mode = "markers")
Image

This seems backwards since I added the type="scatter" to avoid the warning about guessing the trace type, only to have my palette disappear.

Curiously, this behavior isn't present if everything is specified in the same call:

plot_ly(data = iris, x = ~Sepal.Length, y = ~Sepal.Width, color = ~Species, colors = "Blues")
plot_ly(data = iris, x = ~Sepal.Length, y = ~Sepal.Width, color = ~Species, colors = "Blues", type="scatter")

both return

Image

Is colors the correct way to pass a palette to a specific layer? In other places it seems like it's actually colorspace? I know scatter doesn't have a colors argument in schema() (e.g. #1699) but clearly it's working when the type is inferred and I would like to provide a palette...

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus plotly/plotly.R

Alle Issues in plotly/plotly.R

Ähnliche Issues

Weitere Issues zu R

Neue Issues direkt in Ihr Postfach

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