plotly / plotly/plotly.R

`ggplotly` modifies values before creating tooltip

Open
#1,849 1 comment 0 reactions 0 assignees View on GitHub

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:

Screen Shot 2020-09-12 at 4 53 06 PM

This may be related to #560, #616 or #874. It was reported on StackOverflow here: https://stackoverflow.com/q/63862157/2554330

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.