plotly / plotly/plotly.R

ggplotly ignores scale_y_discrete(breaks = NULL)

Open
#1,154 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

ggplot_2

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

ggplotly_2

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.