Reputation: 742
I am using plotly package to make a heatmap. However, the tooltips show "x,y,z" instead of "Base, weekday, count". Please guide me on how to fix this issue as I'm new to plotly package. My code is:
p<-plot_ly(x=colnames(df_base_dayofweek_m), y=rownames(df_base_dayofweek_m), z = df_base_dayofweek_m, type = "heatmap") %>%
layout(margin = list(l=120))
p <- p %>% layout(title = 'Ride count for different bases',margin=m,
titlefont = list(size = 38, color = "black", family = "Calibri"),
xaxis = list(title = 'Bases',tickfont = list(size = 15), ticktext = sprintf("<b>%s</b>",
levels(factor(df_base_dayofweek_label$Base))),
tickvals = levels(factor(df_base_dayofweek_label$Base)),
titlefont = list(color = "black",size = 28, family = "Arial")),
yaxis = list(title = 'Weekday',tickfont = list(size = 15),ticktext = sprintf("<b>%s</b>",
levels(factor(df_base_dayofweek_label$dayofweek))),
tickvals = levels(factor(df_base_dayofweek_label$dayofweek)),
titlefont = list(color = "black",size = 28,family = "Arial")))
p
Thanks!
Upvotes: 0
Views: 42
Reputation: 33397
As you haven't provided any data I'm taking an example from here.
You can use plot_ly
s argument hovertemplate
to modify the hoverinfo:
library(plotly)
fig <- plot_ly(z = volcano,
type = "heatmap",
hovertemplate = "Base: %{x}<br>Weekday: %{y}<br>Count: %{z}<extra></extra>")
fig
Upvotes: 1