Skip to content

Commit 78410cc

Browse files
authored
px example in heatmap (#2000)
1 parent 14dc3fe commit 78410cc

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

doc/python/heatmaps.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: '1.1'
9-
jupytext_version: 1.1.1
8+
format_version: '1.2'
9+
jupytext_version: 1.3.0
1010
kernelspec:
1111
display_name: Python 3
1212
language: python
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.6.7
23+
version: 3.7.3
2424
plotly:
2525
description: How to make Heatmaps in Python with Plotly.
2626
display_as: scientific
@@ -34,7 +34,26 @@ jupyter:
3434
thumbnail: thumbnail/heatmap.jpg
3535
---
3636

37-
### Basic Heatmap
37+
### Heatmap with `plotly.express` and `px.imshow`
38+
39+
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly. With `px.imshow`, each value of the input array is represented as a heatmap pixel.
40+
41+
`px.imshow` makes opiniated choices for representing heatmaps, such as using square pixels. To override this behaviour, you can use `fig.update_layout` or use the `go.Heatmap` trace from `plotly.graph_objects` as described below.
42+
43+
For more examples using `px.imshow`, see the [tutorial on displaying image data with plotly](/python/imshow).
44+
45+
```python
46+
import plotly.express as px
47+
48+
fig = px.imshow([[1, 20, 30],
49+
[20, 1, 60],
50+
[30, 60, 1]])
51+
fig.show()
52+
```
53+
54+
### Basic Heatmap with `plotly.graph_objects`
55+
56+
If Plotly Express does not provide a good starting point, it is also possible to use the more generic `go.Heatmap` function from `plotly.graph_objects`.
3857

3958
```python
4059
import plotly.graph_objects as go

0 commit comments

Comments
 (0)