Skip to content

Commit bd06f3b

Browse files
committed
fix color_continuous_scale
1 parent 7696258 commit bd06f3b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

python/imshow.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fig.show()
7777

7878
### Display single-channel 2D image as grayscale
7979

80-
For a 2D image, `px.imshow` uses a colorscale to map scalar data to colors. The default colorscale is `gray`, ie grayscale images.
80+
For a 2D image, `px.imshow` uses a colorscale to map scalar data to colors. The default colorscale is the one of the active template (see [the tutorial on templates](/python/templates/)).
8181

8282
```python
8383
import plotly.express as px
@@ -94,7 +94,7 @@ fig.show()
9494
import plotly.express as px
9595
import numpy as np
9696
img = np.arange(100).reshape((10, 10))
97-
fig = px.imshow(img, colorscale='Viridis')
97+
fig = px.imshow(img, color_continuous_scale='gray')
9898
fig.show()
9999
```
100100

@@ -116,7 +116,7 @@ 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-
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:
119+
For single-channel data, the defaults values of `zmin` and `zmax` used by `px.imshow` and `go.Heatmap` are 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.
121121
- 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

@@ -162,7 +162,7 @@ import plotly.express as px
162162
import plotly.graph_objects as go
163163
from skimage import data
164164
img = data.camera()
165-
fig = px.imshow(img)
165+
fig = px.imshow(img, color_continuous_scale='gray')
166166
fig.add_trace(go.Contour(z=img, showscale=False,
167167
contours=dict(start=0, end=70, size=70, coloring='lines'),
168168
line_width=2))
@@ -189,7 +189,3 @@ 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)