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
Customize the title shown in unified hovermode, by specifing `unifiedhovertitle.text`.
91
+
92
+
The unified hover title is a template string that supports using variables from the data. Numbers are formatted using d3-format's syntax `%{variable:d3-format}`, for `example \"Price: %{y:$.2f}\"`. Dates are formatted using d3-time-format's syntax `%{variable|d3-time-format}`, for example `\"Day: %{2019-01-01|%A}\"`.
93
+
94
+
The following example uses `'x unified'` hover and specifies a unified hover title that shows the full weekday, month, day, and year.
95
+
96
+
```python
97
+
import plotly.graph_objects as go
98
+
import plotly.express as px
99
+
100
+
df = px.data.stocks()
101
+
102
+
fig = go.Figure(
103
+
data=[
104
+
go.Scatter(
105
+
x=df['date'],
106
+
y=df['GOOG'],
107
+
mode='lines',
108
+
name='Google'
109
+
),
110
+
go.Scatter(
111
+
x=df['date'],
112
+
y=df['AAPL'],
113
+
mode='lines',
114
+
name='Apple'
115
+
)
116
+
],
117
+
layout=go.Layout(
118
+
title_text="Stock Prices with Custom Unified Hover Title",
119
+
hovermode='x unified',
120
+
xaxis=dict(
121
+
title_text='Date',
122
+
unifiedhovertitle=dict(
123
+
text='<b>%{x|%A, %B %d, %Y}</b>'
124
+
)
125
+
),
126
+
yaxis=dict(
127
+
title_text='Price (USD)',
128
+
tickprefix='$'
129
+
)
130
+
)
131
+
)
132
+
133
+
fig.show()
134
+
135
+
```
136
+
86
137
#### Control hovermode with Dash
87
138
88
139
[Dash](https://plotly.com/dash/) is the best way to build analytical apps in Python using Plotly figures. To run the app below, run `pip install dash`, click "Download" to get the code and run `python app.py`.
0 commit comments