You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To customize the tooltip on your graph you can use [hovertemplate](https://plot.ly/python/reference/#pie-hovertemplate), which is a template string used for rendering the information that appear on hoverbox.
110
+
This template string can include `variables` in %{variable} format, `numbers` in [d3-format's syntax](https://github.com/d3/d3-3.x-api-reference/blob/master/Formatting.md#d3_forma), and `date` in [d3-time-fomrat's syntax](https://github.com/d3/d3-3.x-api-reference/blob/master/Time-Formatting.md#format).
111
+
Hovertemplate customize the tooltip text vs. [texttemplate](https://plot.ly/python/reference/#pie-texttemplate) which customizes the text that appears on your chart.
112
+
113
+
```python
114
+
import plotly.graph_objects as go
115
+
116
+
fig = go.Figure(go.Scatter(
117
+
x= [1,2,3,4,5],
118
+
y= [2.02825,1.63728,6.83839,4.8485,4.73463],
119
+
hovertemplate=
120
+
'<i>Price</i>: $%{y:.2f}'+
121
+
'<br><b>X</b>: %{x}<br>'+
122
+
'<b>%{text}</b>',
123
+
text= ['Custom text {}'.format(i +1) for i inrange(5)],
124
+
showlegend=False))
125
+
126
+
fig.add_trace(go.Scatter(
127
+
x= [1,2,3,4,5],
128
+
y= [3.02825,2.63728,4.83839,3.8485,1.73463],
129
+
hovertemplate='Price: %{y:$.2f}<extra></extra>',
130
+
showlegend=False))
131
+
132
+
fig.update_layout(title="Set hover text with hovertemplate")
The following example shows how to format hover template. [Here](https://plot.ly/python/v3/hover-text-and-formatting/#dash-example) is an example to see how to format hovertemplate in Dash.
0 commit comments