Custom dimensions for a ggplot2 boxplot doesn't work with ggplotly
Personne n'a encore pris cette issue.
- Langage dominant
- R
- Étoiles
- 2.7k
- Forks
- 641
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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!
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par l’exemple R reproductible dans l’issue et comparez ggplotly(g1) à ggplotly(g2), en vous concentrant sur le boxplot avec stat="identity" et les mappages personnalisés de ymin, lower, middle, upper et ymax. Reproduisez l’échec, puis suivez le chemin de conversion de ggplotly pour ces valeurs du boxplot ; le travail est terminé lorsque le graphique avec des dimensions personnalisées s’affiche tout en conservant les points aberrants.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- r
- Domaine
- data-visualization
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100