plotly / plotly/plotly.R

ggplotly does not respect the `width` of tiles, fills the "no data" range instead

Offen
#1,957 1 Kommentar 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

ggplotly does not respect the width value used for tiles. In the examples, the tiles should have a constant width, but converting the visualisation with ggplotly() results in a different visualisation, in which the areas with no data associated are "filled in" by the bordering tiles. It looks like the tiles expand on both sides equally, just enough to fill the empty space.

Note that what is meant by "no data" here is different to "missing data": the x value has no corresponding row in the dataset.

library(ggplot2)
library(plotly)
# default tile width
(default_width <- ggplot(mapping = aes(x = c(1, 2, 4), y = 1, fill = 1:3)) +
   geom_tile())

Convert to plotly:

ggplotly(default_width)

default

If one provides a custom width for the tiles, ggplotly() still ignores it:

# custom tile width
(custom_width <- ggplot(mapping = aes(x = c(1, 2, 4), y = 1, fill = 1:3)) +
    geom_tile(width = .5))

Convert to plotly:

ggplotly(custom_width)

custom

This does not happen if doing something similar with geom_col().

Using:

  • R 4.1.0
  • ggplot2 3.3.3
  • plotly 4.9.3

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

Reproduziere das Problem anhand der R-Beispiele mit ggplotly() und geom_tile(), wobei die Fälle mit Standardbreite und benutzerdefinierter Breite mit dem Verhalten von geom_col() verglichen werden. Verfolge die Umwandlung der Kachelbreiten durch ggplotly() und überprüfe, dass Lücken für x-Werte ohne Zeilen leer bleiben und dass geom_tile(width = .5) berücksichtigt wird.

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.