0

I have a plotly histogram where x-axis is log tranformed. I'm trying to make my histogram tooltip show the original value rather than the log10-transformed value. I'm referring to this example. Overwriting the text attribute.

Below is my code. However, my tooltip does not show anything. Does anyone know how I can modify the text attributes in this case?

g=iris %>% 
  #select(Petal.Length) %>% 
  ggplot(aes(x=Petal.Length))+
  geom_histogram()+
  scale_x_log10()
gg <- ggplotly(g)
gg$x$data[[1]]$text = paste(x,y)
gg
zesla
  • 11,155
  • 16
  • 82
  • 147

1 Answers1

0

Define what you want to show inside aes(), and then call it in ggplotly.

g=iris %>% 
  ggplot(aes(x=Petal.Length, text=paste("X:",iris$Petal.Length) )) +
  geom_histogram()+
  scale_x_log10()
gg <- ggplotly(g, tooltip=c("text"))
gg
YBS
  • 19,324
  • 2
  • 9
  • 27