plotly / plotly/plotly.R

ggplotly not rendering geom_ribbon() correctly with NA values

Open
#1,060 3 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.