- Notifications
You must be signed in to change notification settings - Fork1
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
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
12 commits Select commitHold shift + click to select a range
cfac436
new tutorial on displaying image data
emmanuelle2056d13
minor changes
emmanuelle10d64b9
minor changes
emmanuelle4654c06
updated how to disable ticks
emmanuellef97dfc4
zmax update
emmanuelle4f3bc89
new tutorial on displaying image data
emmanuelle67c1830
minor changes
emmanuellecc59b3c
minor changes
emmanuelle9d01e29
updated how to disable ticks
emmanuelle4e93741
zmax update
emmanuelle7696258
Merge branch 'image' of https://github.com/plotly/plotly.py-docs into…
emmanuellebd06f3b
fix color_continuous_scale
emmanuelleFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
minor changes
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit67c18302626f3fe2b9c2e59493d53153be6f26e8
There are no files selected for viewing
42 changes: 18 additions & 24 deletionspython/images.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -34,7 +34,7 @@ jupyter: | ||
#### Add a Background Image | ||
In this page we explain how to add static, non-interactive images as background, logo or annotation images to a figure. For exploring image data in interactive charts, see the [tutorial on displaying image data](/python/imshow). | ||
nicolaskruchten marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
```python | ||
import plotly.graph_objects as go | ||
@@ -48,8 +48,7 @@ fig.add_trace( | ||
) | ||
# Add images | ||
fig.add_layout_image( | ||
go.layout.Image( | ||
source="https://images.plot.ly/language-icons/api-home/python-logo.png", | ||
xref="x", | ||
@@ -61,7 +60,6 @@ fig.update_layout( | ||
sizing="stretch", | ||
opacity=0.5, | ||
layer="below") | ||
) | ||
# Set templates | ||
@@ -114,14 +112,14 @@ fig.add_trace( | ||
) | ||
# Add image | ||
fig.add_layout_image( | ||
dict( | ||
source="https://raw.githubusercontent.com/cldougl/plot_images/add_r_img/vox.png", | ||
xref="paper", yref="paper", | ||
x=1, y=1.05, | ||
sizex=0.2, sizey=0.2, | ||
xanchor="right", yanchor="bottom" | ||
) | ||
) | ||
# update layout properties | ||
@@ -173,30 +171,26 @@ for (x, y), n in zip(simulated_absorptions, names): | ||
fig.add_trace(go.Scatter(x=x, y=y, name=n)) | ||
# Add images | ||
fig.add_layout_image( | ||
go.layout.Image( | ||
source="https://raw.githubusercontent.com/michaelbabyn/plot_data/master/benzene.png", | ||
x=0.75, | ||
y=0.65, | ||
)) | ||
fig.add_layout_image(go.layout.Image( | ||
source="https://raw.githubusercontent.com/michaelbabyn/plot_data/master/naphthalene.png", | ||
x=0.9, | ||
y=0.3, | ||
) | ||
) | ||
fig.update_layout_images(dict( | ||
xref="paper", | ||
yref="paper", | ||
sizex=0.3, | ||
sizey=0.3, | ||
xanchor="right", | ||
yanchor="bottom" | ||
)) | ||
# Add annotations | ||
fig.update_layout( | ||
@@ -279,8 +273,8 @@ fig.update_yaxes( | ||
) | ||
# Add image | ||
fig.add_layout_image( | ||
go.layout.Image( | ||
x=0, | ||
sizex=img_width * scale_factor, | ||
y=img_height * scale_factor, | ||
@@ -290,7 +284,7 @@ fig.update_layout( | ||
opacity=1.0, | ||
layer="below", | ||
sizing="stretch", | ||
source="https://raw.githubusercontent.com/michaelbabyn/plot_data/master/bridge.jpg") | ||
) | ||
# Configure other layout | ||
11 changes: 7 additions & 4 deletionspython/imshow.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -37,6 +37,10 @@ jupyter: | ||
v4upgrade: true | ||
--- | ||
nicolaskruchten marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
This tutorial shows how to display and explore image data. If you would like | ||
instead a logo or static image, use `go.layout.Image` as explained | ||
[here](/python/images). | ||
### Displaying RBG image data with px.imshow | ||
`px.imshow` displays multichannel (RGB) or single-channel ("grayscale") image data. | ||
@@ -73,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. | ||
```python | ||
import plotly.express as px | ||
@@ -85,7 +89,6 @@ fig.show() | ||
### Choose the colorscale to display a single-channel image | ||
nicolaskruchten marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
```python | ||
import plotly.express as px | ||
@@ -97,9 +100,9 @@ fig.show() | ||
### Display multichannel image data with go.Image | ||
It is also possible to use the `go.Image` trace from the low-level `graph_objects` API in order to display image data. Note that `go.Image` only accepts multichannel images. For single images, use [`go.Heatmap`](/python/heatmaps). | ||
Note that the `go.Image` trace is different from the `go.layout.Image` class, which can be used for [adding background images or logos to figures](/python/images). | ||
```python | ||
import plotly.graph_objects as go | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.