Skip to content

ggplotly modifies values before creating tooltip #1849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dmurdoch opened this issue Sep 12, 2020 · 1 comment
Open

ggplotly modifies values before creating tooltip #1849

dmurdoch opened this issue Sep 12, 2020 · 1 comment

Comments

@dmurdoch
Copy link
Contributor

dmurdoch commented Sep 12, 2020

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

@wcwr wcwr mentioned this issue Nov 4, 2022
@wcwr
Copy link

wcwr commented Nov 4, 2022

The issue is still unresolved, but adding geom_point will at least show the correct value in tooltip :

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") +
  geom_point(size=4) #Add geom_point
ggplotly(p1, tooltip = c("y", "z"))

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants