plotly / plotly/plotly.R

ggplotly doesn't display geom_rect with ymin = -Inf and ymax = Inf

Ouverte
#1,559 6 commentaires 17 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

bug ggplotly
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

image

# Calling ggplotly
example_plot %>% ggplotly()

image

Note ggplotly image above captured using 'export' function on Viewer pane in RStudio.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. 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

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.