Skip to content

Commit c19b99a

Browse files
committed
Updated histogram example
1 parent 9638675 commit c19b99a

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

Diff for: doc/python/histograms.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -210,18 +210,12 @@ fig.show()
210210

211211
### Adding bar text
212212

213-
You can add text to histogram bars using `fig.update_traces(texttemplate="%{variable}")`, where `variable` is the text to add. In this example, we add the y-axis values to the bars. We get these values following the **Accessing the counts (y-axis) values** example above.
213+
You can add text to histogram bars using `fig.update_traces(texttemplate="%{variable}")`, where `variable` is the text to add. In this example, we add the y-axis values to the bars.
214214

215215
```python
216216
import plotly.express as px
217-
import numpy as np
218-
219217
df = px.data.tips()
220-
221-
counts, bins = np.histogram(df.total_bill, bins=range(0, 60, 5))
222-
bins = 0.5 * (bins[:-1] + bins[1:])
223-
224-
fig = px.bar(x=bins, y=counts, labels={'x':'total_bill', 'y':'count'})
218+
fig = px.histogram(df, x="total_bill", y="tip", histfunc='avg', nbins=8)
225219
fig.update_traces(texttemplate="%{y}")
226220
fig.show()
227221
```

0 commit comments

Comments
 (0)