Skip to content

Commit 280b72a

Browse files
committed
2D-Histogram and heatmaps
1 parent 6228e27 commit 280b72a

File tree

3 files changed

+48
-10
lines changed

3 files changed

+48
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<table>
44
<tr>
5-
<td>Latest Release</td>
6-
<td>
5+
<td>Latest Release</td>
6+
<td>
77
<a href="https://pypi.org/project/plotly/"/>
88
<img src="https://badge.fury.io/py/plotly.svg"/>
99
</td>

doc/python/2D-Histogram.md

Lines changed: 23 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.2
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.0
2424
plotly:
2525
description: How to make 2D Histograms in Python with Plotly.
2626
display_as: statistical
@@ -235,5 +235,24 @@ fig.update_layout(
235235
fig.show()
236236
```
237237

238+
### Adding text to points
239+
240+
241+
In this example we show how to add text to 2D-Histogram points. We use the values from the `z` attribute for the text, and add them using 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+
fig.show()
255+
```
256+
238257
#### Reference
239258
See https://plotly.com/python/reference/histogram2d/ for more information and chart attribute options!

doc/python/heatmaps.md

Lines changed: 23 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.6.0
8+
format_version: '1.3'
9+
jupytext_version: 1.13.2
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.7.6
23+
version: 3.7.0
2424
plotly:
2525
description: How to make Heatmaps in Python with Plotly.
2626
display_as: scientific
@@ -197,6 +197,25 @@ fig.update_layout(
197197
fig.show()
198198
```
199199

200+
### Adding text to points
201+
202+
203+
In this example we show how to add text to heatmap points. We use the values from the `text` attribute for the text, and add them using the format **%{variable}**.
204+
205+
```python
206+
import plotly.graph_objects as go
207+
208+
fig = go.Figure(data=go.Heatmap(
209+
z=[[1, 20, 30],
210+
[20, 1, 60],
211+
[30, 60, 1]],
212+
text=[['one', 'twenty', 'thirty'],
213+
['twenty', 'one', 'sixty'],
214+
['thirty', 'sixty', 'one']],
215+
texttemplate="%{text}"))
216+
fig.show()
217+
```
218+
200219
### Heatmap and datashader
201220

202221
Arrays of rasterized values build by datashader can be visualized using

0 commit comments

Comments
 (0)