Skip to content

Commit 5c00b07

Browse files
committed
2D Histogram text on points example
1 parent 7c63767 commit 5c00b07

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

doc/python/2D-Histogram.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: '1.2'
9-
jupytext_version: 1.3.1
8+
format_version: '1.3'
9+
jupytext_version: 1.13.4
1010
kernelspec:
11-
display_name: Python 3
11+
display_name: Python 3 (ipykernel)
1212
language: python
1313
name: python3
1414
language_info:
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.6.8
23+
version: 3.7.11
2424
plotly:
2525
description: How to make 2D Histograms in Python with Plotly.
2626
display_as: statistical
@@ -235,5 +235,25 @@ fig.update_layout(
235235
fig.show()
236236
```
237237

238+
### Text on 2D Histogram Points
239+
240+
241+
In this example we add text to 2D-Histogram points. We use the values from the `z` attribute for the text, adding them following the format **%{variable}**.
242+
243+
```python
244+
import plotly.graph_objects as go
245+
from plotly import data
246+
247+
df = data.tips()
248+
249+
fig = go.Figure(go.Histogram2d(
250+
x=df.total_bill,
251+
y=df.tip,
252+
texttemplate= "%{z}"
253+
))
254+
255+
fig.show()
256+
```
257+
238258
#### Reference
239259
See https://plotly.com/python/reference/histogram2d/ for more information and chart attribute options!

0 commit comments

Comments
 (0)