ggplotly doesn't display geom_rect with ymin = -Inf and ymax = Inf
Nessuno ha ancora preso questa issue.
- Lingua principale
- R
- Stelle
- 2.7k
- Fork
- 641
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo tramite ggplotly() l'esempio fornito con economics e geom_rect, quindi segui il punto di ingresso della conversione ggplotly per geom_rect. Confronta il ggplot di base con l'output renderizzato; il lavoro è completato quando i rettangoli con ymin = -Inf e ymax = Inf vengono visualizzati fino ai limiti dell'area del grafico.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- plotly, r
- Ambito
- data-visualization
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100