`ggplotly()` function does not respect line width and does not show legend lines of `geom_linearange()`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- R
- Sterne
- 2.7k
- Forks
- 641
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Trying to apply ggplotly() to the following ggplot + geom_linerange() resulted in a faulted graph: the line width is not respected (or considered) and the legend does not show the lines for each key (what line of what color corresponds to each entry?)
``` r
library(tidyverse)
library(plotly)
df = tibble(
task = c("Job A", "Job B", "Job C", "Job A"),
start = c(0, 5, 10, 6),
end = c(4, 9, 15, 7),
resource=c ('Alex', 'Max', 'Max', 'Alex')
)
p <- ggplot(data = df,
aes(x = start,
y = task
)
) +
geom_linerange(aes(xmin = start,
xmax = end,
color = resource
),
size = 5.5,
alpha = 0.76
) +
labs(x = "Time (s)",
y = "Tasks",
color = "",
title = "Gantt plot (ggplot)")
print(p)
ggplot output:

but ggplotly:
ply <- ggplotly(p)
print(ply)
output:

Session info
sessionInfo()
#> R version 4.1.3 (2022-03-10)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19043)
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] plotly_4.10.0 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.9
#> [5] purrr_0.3.4 readr_2.1.2 tidyr_1.2.0 tibble_3.1.7
#> [9] ggplot2_3.3.6 tidyverse_1.3.1
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 damit, das reproduzierbare R-Beispiel des Issues mit ggplotly() auszuführen und mit der ggplot-Ausgabe zu vergleichen. Verfolge, wie geom_linerange() konvertiert wird und wie sein size- und resource-Farbmapping den interaktiven Graphen erreichen. Als abgeschlossen gilt die Aufgabe, wenn der konvertierte Plot die angeforderte Linienbreite berücksichtigt und die Legende repräsentative Linien für jede Ressource anzeigt.
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
- 42/100