`ggplotly` modifies values before creating tooltip
Open
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
When drawing a geom_bar plot with negative values, a tooltip will display them as positive instead.
library(ggplot2)
library(plotly)
dataset <- data.frame(x = 1:2, y = 1:2 - 3, z = 1:2 - 3) # z == y
p1 <- ggplot(dataset, aes(x, y, z = z)) + geom_bar(stat = "identity")
ggplotly(p1, tooltip = c("y", "z"))
Even though y and z contain the same negative values, only z is displayed as negative in the tooltip:

This may be related to #560, #616 or #874. It was reported on StackOverflow here: https://stackoverflow.com/q/63862157/2554330
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 ggplotly example with geom_bar and tooltip fields y and z, then trace how ggplotly converts the plot data before building tooltips. Done means negative y and z values remain negative and display consistently in both tooltips.
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
- 42/100