ggplotly doesn't display geom_rect with ymin = -Inf and ymax = Inf
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
In ggplot::geom_rect(), one can specify the aesthetics ymin = -Inf and ymax = Inf, which will draw the rectangles to the limit of the plotting area. Apparently, ggplotly does not support this behaviour, and will fail to display the rectangles when a ggplot object with such a geom_rect is passed.
Motivation This behaviour of geom_rect is especially useful for indicating time periods of interest when plotting time series. Workarounds such as manually specifying the ymin and ymax limits to mimic the behaviour are much less effective: it can be difficult to know in advance what those limits should be, and they are affected by expand settings in the scale specification.
# Plot definition
example_plot = economics %>%
ggplot() +
geom_line(aes(x = date, y = psavert)) +
geom_rect(data = data.frame(xmin = seq(as.Date('1970-01-01'),
as.Date('2010-01-01'),
'10 years'),
xmax = seq(as.Date('1975-01-01'),
as.Date('2015-01-01'),
'10 years'),
ymin = -Inf, ymax = Inf),
aes(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax))
# Base ggplot object
example_plot

# Calling ggplotly
example_plot %>% ggplotly()

Note ggplotly image above captured using 'export' function on Viewer pane in RStudio.
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 exécuter via ggplotly() l’exemple fourni avec economics et geom_rect, puis suivez le point d’entrée de la conversion ggplotly pour geom_rect. Comparez le ggplot de base et la sortie rendue ; c’est terminé lorsque les rectangles avec ymin = -Inf et ymax = Inf s’affichent jusqu’aux limites de la zone de tracé.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- plotly, 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