Skip to content

Commit f97dfc4

Browse files
committed
zmax update
1 parent 4654c06 commit f97dfc4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

python/imshow.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ For a 2D image, `px.imshow` uses a colorscale to map scalar data to colors. The
8282
```python
8383
import plotly.express as px
8484
import numpy as np
85-
img = np.arange(100).reshape((10, 10))
85+
img = np.arange(15**2).reshape((15, 15))
8686
fig = px.imshow(img)
8787
fig.show()
8888
```
@@ -116,11 +116,11 @@ fig.show()
116116

117117
The data range and color range are mapped together using the parameters `zmin` and `zmax`, which correspond respectively to the data values mapped to black `[0, 0, 0]` and white `[255, 255, 255]`, or to the extreme colors of the colorscale in the case on single-channel data.
118118

119-
`px.imshow` and `go.Image` use slightly different default values for `zmin` and `zmax`. For `go.Image`, the default value is `zmin=[0, 0, 0]` and `zmax=[255, 255, 255]`, no matter the data type. On the other hand, `px.imshow` adapts the default `zmin` and `zmax` to the data type:
119+
For single-channel data, the defaults values of `zmin` and `zmax` used by `px.imshow` and `go.Heatmap` are the the extrema of the data range. For multichannel data, `px.imshow` and `go.Image` use slightly different default values for `zmin` and `zmax`. For `go.Image`, the default value is `zmin=[0, 0, 0]` and `zmax=[255, 255, 255]`, no matter the data type. On the other hand, `px.imshow` adapts the default `zmin` and `zmax` to the data type:
120120
- for integer data types, `zmin` and `zmax` correspond to the extreme values of the data type, for example 0 and 255 for `uint8`, 0 and 65535 for `uint16`, etc.
121-
- for float numbers, when the data range is more arbitrary, the minimum and maximum values of the image (across all channels) is used.
121+
- for float numbers, the maximum value of the data is computed, and zmax is 1 if the max is smaller than 1, 255 if the max is smaller than 255, etc. (with higher thresholds 2**16 - 1 and 2**32 -1).
122122

123-
These defaults can be overriden by setting the values of `zmin` and `zmax`. For `go.Image`, `zmin` and `zmax` need to be given for all channels, whereas it is also possible to pass a scalar value (used for all channels) go `px.imshow`.
123+
These defaults can be overriden by setting the values of `zmin` and `zmax`. For `go.Image`, `zmin` and `zmax` need to be given for all channels, whereas it is also possible to pass a scalar value (used for all channels) to `px.imshow`.
124124

125125
```python
126126
import plotly.express as px
@@ -189,3 +189,7 @@ fig.show()
189189
#### Reference
190190
See https://plot.ly/python/reference/#image for more information and chart attribute options!
191191

192+
193+
```python
194+
fig = px.imshow
195+
```

0 commit comments

Comments
 (0)