Issue when specifying both the size and color mapping in a scatter plots
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- R
- Sterne
- 2.7k
- Forks
- 641
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Hi,
I can not manage to specify both the size and the color mapping with completely satisfactory results.
If I specify the size mapping globally:
library(plotly)
df <- data.frame(x = 1:12, y = 1:12, s = 1:12, g = rep(c("A", "B", "C"), 4))
plot_ly(data = df, x = ~x, y = ~y, size = ~s, color= ~g)%>%
add_markers()
I have a perfect plot but I suffer from the spurious line.width warning already mentioned in https://github.com/ropensci/plotly/issues/1367
If I specify the size mapping in the marker itself:
plot_ly(data = df, x = ~x, y = ~y, color= ~g)%>%
add_markers(marker = list(size = ~s))
The sizes are wrong: it seems there is an ordering by group within plotly which is not used in the markers.
Indeed, sorting the data.frame according to the colors fixes the issue:
df_sorted = df[order(df[['g']]), ]
plot_ly(data = df_sorted, x = ~x, y = ~y, color= ~g)%>%
add_markers(marker = list(size = ~s))
Let me know how I can help!
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit den beiden unsortierten Beispielen mit plot_ly() und add_markers(), und vergleiche anschließend deren Verhalten bei der Markergröße mit dem Beispiel mit dem sortierten data.frame. Verfolge, wie Farbgruppierung und Zuordnungen der Markergrößen aufeinander abgestimmt sind, und überprüfe, dass unsortierte Daten die vorgesehenen Größen ohne die gemeldete line.width-Warnung beibehalten.
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