Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

new tutorial on displaying image data#163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolaskruchten merged 12 commits intov4.3-docsfromimage
Nov 12, 2019
Merged
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
fix color_continuous_scale
  • Loading branch information
@emmanuelle
emmanuelle committedNov 12, 2019
commitbd06f3b44a6b1676bc035702ad39083b597fa02b
12 changes: 4 additions & 8 deletionspython/imshow.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,7 +77,7 @@ fig.show()

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

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

```python
import plotly.express as px
Expand All@@ -94,7 +94,7 @@ fig.show()
import plotly.express as px
import numpy as np
img = np.arange(100).reshape((10, 10))
fig = px.imshow(img,colorscale='Viridis')
fig = px.imshow(img,color_continuous_scale='gray')
fig.show()
```

Expand All@@ -116,7 +116,7 @@ fig.show()

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.

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

Expand DownExpand Up@@ -162,7 +162,7 @@ import plotly.express as px
import plotly.graph_objects as go
from skimage import data
img = data.camera()
fig = px.imshow(img)
fig = px.imshow(img, color_continuous_scale='gray')
fig.add_trace(go.Contour(z=img, showscale=False,
contours=dict(start=0, end=70, size=70, coloring='lines'),
line_width=2))
Expand All@@ -189,7 +189,3 @@ fig.show()
#### Reference
See https://plot.ly/python/reference/#image for more information and chart attribute options!


```python
fig = px.imshow
```

[8]ページ先頭

©2009-2025 Movatter.jp