Custom dimensions for a ggplot2 boxplot doesn't work with ggplotly
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 I create a ggplot2 boxplot with custom dimensions (see the bottom of http://ggplot2.tidyverse.org/reference/geom_boxplot.html#examples), plotly doesn't render the boxplot when I apply ggplotly. However, it works ok with a traditional boxplot where the dimensions are calculated by geom_boxplot/stat_boxplot.
Below is a reproducible example of the issue.
## Libraries
library(ggplot2)
library(plotly)
## Using fake data with extreme values
fake_data = data.frame(
y1 = c(rnorm(100, 2, 3), rnorm(10, 10, 15))
)
# ggplot2
g1 = ggplot(data=fake_data, aes(x ="cat1", y= y1)) +
#stat_boxplot(geom="errorbar") +
geom_boxplot() +
labs(title="Traditional Boxplot") +
ylim(c(-5, 25))
g1
quants = quantile(fake_data$y1, c(0.05, .25, .5, .75, .95))
q_df = data.frame(t(quants))
names(q_df) = c("y5", "y25", "y50", "y75", "y95")
g2 = ggplot(data=q_df, aes(x ="cat1")) +
#stat_boxplot(geom="errorbar") +
geom_boxplot(stat="identity", aes(,
ymin = y5, lower = y25,
middle = y50, upper = y75,
ymax = y95)) +
geom_point(data=subset(fake_data, (y1 > q_df$y95) | (y1 < q_df$y5)), aes(y=y1)) +
labs(title="5%/95% Boxplot") +
ylim(c(-5, 25))
g2
# plotly
plotly::ggplotly(g1)
plotly::ggplotly(g2) # DOESN'T WORK!
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
Beginnen Sie mit dem reproduzierbaren R-Beispiel im Issue und vergleichen Sie ggplotly(g1) mit ggplotly(g2), mit Fokus auf dem Boxplot mit stat="identity" und den benutzerdefinierten Zuordnungen für ymin, lower, middle, upper und ymax. Reproduzieren Sie den Fehler und verfolgen Sie anschließend den ggplotly-Konvertierungspfad für diese Boxplot-Werte; abgeschlossen ist die Aufgabe, wenn das Diagramm mit benutzerdefinierten Dimensionen gerendert wird und die Ausreißerpunkte erhalten bleiben.
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