plotly / plotly/plotly.R

Annotations for factor in barplot misplaced

Offen
#2,211 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

When adding annotations to a barplot with x as factor, the plot gets squished
Problem arises since R plotly version 4.10.1. Worked fine until plotly 4.9.2.1

This works not

plotData <- data.frame(x = factor(1991:2000), y = rnorm(10))
plot_ly(data = plotData, x = ~x, y = ~y, type = "bar") %>%
  layout(annotations = list(x = plotData$x, y = 0, text = 1:10))

Screenshot from 2022-12-02 17-14-44

This works, although it is safer to match on the actual x-values (factor levels) rather than on a numeric variant (mind the -1 to get it start at 0!)

plotData <- data.frame(x = factor(1991:2000), y = rnorm(10))
plot_ly(data = plotData, x = ~x, y = ~y, type = "bar") %>%
  layout(annotations = list(x = as.numeric(plotData$x) - 1, y = 0, text = 1:10))

Screenshot from 2022-12-02 17-15-09

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

Beginnen Sie mit der bereitgestellten Reproduktion von plot_ly() und layout(annotations = ...) unter Verwendung von x-Werten des Typs factor und vergleichen Sie das Verhalten zwischen plotly.R 4.9.2.1 und 4.10.1. Verfolgen Sie, wie factor-Annotationen konvertiert werden, und überprüfen Sie, dass die Annotationen an den Balkenkategorien ausgerichtet bleiben, ohne numerische factor-Werte zu erfordern.

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
45/100

Neue Issues direkt in Ihr Postfach

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