Skip to content

Commit db090b8

Browse files
committed
label aliases example
1 parent 8a151e1 commit db090b8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

doc/python/axes.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,23 @@ fig.update_yaxes(ticklabelposition="inside top", title=None)
154154
fig.show()
155155
```
156156

157+
#### Specifying Label Aliases
158+
159+
With `labelalias`, you can specify replacement text for specific tick and hover labels. In this example, the dataset has the weekend days as "Sat" and "Sun". By setting `labelalias=dict(Sun="Sunday", Sat= "Saturday")`, we spell the days out in full.
160+
161+
```python
162+
import plotly.express as px
163+
import pandas as pd
164+
165+
df = px.data.tips()
166+
df = df[df.day.isin(['Sat', 'Sun'])].groupby(by='day', as_index=False).sum(numeric_only=True)
167+
168+
fig = px.bar(df, x="day", y="total_bill")
169+
fig.update_xaxes(labelalias=dict(Sun="Sunday", Sat= "Saturday"))
170+
171+
fig.show()
172+
```
173+
157174
##### Set axis title text with Graph Objects
158175

159176
Axis titles are set using the nested `title.text` property of the x or y axis. Here is an example of creating a new figure and using `update_xaxes` and `update_yaxes`, with magic underscore notation, to set the axis titles.

0 commit comments

Comments
 (0)