scale_x_reverse() works with ggplot but not with ggplotly
Open
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
Perhaps this bug should be submitted elsewhere, but consider this code under R 3.6.3:
df <- data.frame(x=c(1,2,3,4,5), y1=c(1,4,9,16,25), y2=c(1,8,27,64,125))
melted.df <- melt(df, id.vars = 'x', variable.name = 'y')
plt <- ggplot(melted.df, aes(x, value)) +
geom_line(aes(colour = y)) +
scale_x_reverse()
plt
This yields a reversed x axis as expected. But do this:
plt %>% ggplotly()
and the reversal happens but all numbers on the x axis scale become negative: -5 -4 -3 -2 -1 in this case.
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
Reproduce the example with R 3.6.3, ggplot2, and ggplotly(), comparing the original reversed axis with the converted plot. Trace the scale_x_reverse() handling during conversion; done means the interactive plot keeps the reversed axis while displaying positive labels such as 5, 4, 3, 2, and 1.
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