ggplotly not rendering geom_ribbon() correctly with NA values
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
ggplotly() creates broken ribbons when there are NAs in the min or max values, although the ribbon is rendered correctly in ggplot alone.
This seems to be alluded to here but since that was 3 years ago I fear it may not be an open issue.
The below is sufficient to illustrate how the plots differ.
Thanks!
library(ggplot2); library(plotly); library(dplyr)
df = data.frame(x = 1:5, y = sin(1:5), min = sin(1:5) + 1, max = sin(1:5)-1) %>%
rbind(c(6,sin(6),NA, NA))
pl = ggplot(df, aes(x=x, y=y)) +
geom_line() +
geom_ribbon(aes(min = min, max = max))
pl
ggplotly(pl)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied R example with ggplot2 and plotly, comparing the ggplot and ggplotly ribbon output when the final min and max values are NA. Trace the ggplotly conversion and rendering path for geom_ribbon(), then verify that ribbons with NA bounds render consistently with ggplot while preserving the existing non-NA behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100