ggplotly date shows wrong when use geom_bar(stat='count')
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- R
- Sterne
- 2.7k
- Forks
- 641
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
I find a problem that, when I use geom_bar(stat='count') to draw a plot and convert to plotly, when pointing to, the label shows date an integer, but when I aggregate the data first and use geom_bar(stat='identity'), the label shows date in proper format. The issue happened after I update to MRO 3.4.1, and try to solve the problem that ggplotly makes graph empty when x axis is date. I update both ggplot2 and plotly to github version that empty problem is gone, but new problem comes.
By the way. Is there a method that control the date format in the label?
devtools::install_github("hadley/ggplot2")
devtools::install_github("ropensci/plotly")
library(ggplot2)
library(plotly)
df2 = data.frame(time = c('2017-01-01 06:00:23', '2017-01-01 10:00:23',
'2017-01-01 18:00:23', '2017-01-01 24:00:23',
'2017-01-02 06:00:23', '2017-01-02 10:00:23',
'2017-01-02 18:00:23', '2017-01-03 24:00:23'),
y = c(1:8))
df2.p = ggplot(df2 %>% mutate(date_id = as.Date(time)), aes(x = date_id, y = ..count..)) +
geom_bar(stat = 'count')
ggplotly(df2.p)
df3 = df2 %>% mutate(date_id = as.Date(time)) %>%
group_by(date_id) %>% summarise(
count = n()
)
df3.p = ggplot(df3, aes(x = date_id, y = count)) +
geom_bar(stat = 'identity')
ggplotly(df3.p)
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 reproduzierbaren R-Beispielen im Issue und vergleiche die ggplotly-Ausgabe für geom_bar(stat='count') mit der Version stat='identity'. Untersuche, wie das date_id-Ästhetik-Attribut in jeder Konvertierung dargestellt wird; als erledigt gilt die Aufgabe, wenn balkenbasierte Zählungen korrekt formatierte Datumsbeschriftungen anzeigen und jegliches Verhalten bei der Datumsformatierung geklärt ist.
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