ggplotly ignores scale_y_discrete(breaks = NULL)
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
In ggplot, scale_y_discrete(breaks = NULL) eliminates axis tick marks and grid lines for the specified discrete axis, like so:

But ggplotly() does not apply this setting, producing this output:

Note that scale_y_discrete(breaks = NULL) does have some impact, by causing the y axis title to overlap the y axis tick mark values, which does not happen if that line of code is omitted.
Reproducible example:
library(ggplot2)
library(dplyr)
library(plotly)
d = data.frame(case = as.factor(rep(1:5, each = 4)),
time = as.factor(rep(1:4, times = 5)))
p = d %>%
ggplot(aes(x = time, y = case)) +
geom_point() +
# suppress the y axis labels and grids (ggplotly ignores this):
scale_y_discrete(breaks = NULL)
print(p) # standard ggplot output has no y axis breaks
ggplotly(p) # but plotly output includes y axis breaks
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 reproducible R example with ggplot2 and plotly, comparing the standard ggplot output with ggplotly(p). Trace how scale_y_discrete(breaks = NULL) is translated by ggplotly; done means the converted plot has no y-axis tick marks, labels, or grid lines, matching ggplot.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- plotly, r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100