Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast image: add binary_string parameter to imshow #2691

Merged
merged 37 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f628e94
Merge branch 'master' of https://github.com/plotly/plotly.py
emmanuelle Jun 12, 2020
d2f8b72
Merge branch 'master' of https://github.com/plotly/plotly.py
emmanuelle Jun 23, 2020
3ef3764
Merge branch 'master' of https://github.com/plotly/plotly.py
emmanuelle Jul 14, 2020
902a98e
Merge branch 'master' of https://github.com/plotly/plotly.py
emmanuelle Jul 27, 2020
71b14c1
run updateplotlyjsdev using js fast-image branch
emmanuelle Aug 5, 2020
1984998
work in progress on imshow with source
emmanuelle Aug 6, 2020
e6feb33
added dev dep
emmanuelle Aug 6, 2020
e551672
added dev dep
emmanuelle Aug 6, 2020
34cc0de
more tests and docstring
emmanuelle Aug 6, 2020
febdfaf
range_color case
emmanuelle Aug 6, 2020
01195f8
values for contrast_rescaling are now minmax and infer
emmanuelle Aug 11, 2020
81ce9f6
vendored code from scikit-image for rescale_intensity
emmanuelle Aug 13, 2020
d3d88b8
different backends for b64 creation
emmanuelle Aug 14, 2020
bd25f05
more tests and documented parameters in docstring
emmanuelle Aug 17, 2020
78d2454
no color in hovertemplate when contrast has been modified
emmanuelle Aug 17, 2020
0752df7
modified tutorial
emmanuelle Aug 17, 2020
34c1acf
modified requirements
emmanuelle Aug 17, 2020
08e0781
solve bug for rgba images
emmanuelle Aug 20, 2020
91f608e
tweaks so that zmin/zmax are set less often
emmanuelle Aug 20, 2020
0cecbd6
do not do anything when origin='lower' because the JS already takes c…
emmanuelle Aug 20, 2020
eeb1988
use z instead of color in hover
emmanuelle Aug 20, 2020
dd21b48
version added in tutorial
emmanuelle Aug 20, 2020
226817e
remove circle ci modifications
emmanuelle Aug 20, 2020
d3cb22b
codegen
emmanuelle Aug 31, 2020
7b117dc
add generated files
emmanuelle Aug 31, 2020
4db5fe4
remove pypng dependency
emmanuelle Aug 31, 2020
63a4dc9
use rgba256 colormodel
emmanuelle Aug 31, 2020
29aab27
try to fix CI
emmanuelle Aug 31, 2020
32ca251
fix test
emmanuelle Aug 31, 2020
cdbfefe
improve examples
emmanuelle Sep 2, 2020
03ce500
add jpg compression option
emmanuelle Sep 2, 2020
c0247d2
improve docstring
emmanuelle Sep 2, 2020
ff6bd6e
bump plotly.js to 1.55.1
nicolaskruchten Sep 3, 2020
3640abc
Merge branch 'master' into fast-image
nicolaskruchten Sep 3, 2020
56494ba
blacken png
nicolaskruchten Sep 3, 2020
cb72f88
remove f-string
nicolaskruchten Sep 3, 2020
96cebe3
fix png.py tests
nicolaskruchten Sep 3, 2020
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
7 changes: 6 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@ jobs:
if [ "${CIRCLE_BRANCH}" != "doc-prod" ]; then
pip uninstall -y plotly
cd ../packages/python/plotly
# To be removed after plotly.js release
pip install inflect black tox
python3 setup.py updateplotlyjsdev --devbranch fast-image
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my idea here was to be able to take a look at the doc even when the corresponding feature is not released in plotly.js, but it does not work since the exported html asks for the regular plotly.js bundle so the feature is not available. Too bad! Or maybe I can find a way to link to another bundle...

python3 setup.py install
cd ../../../doc
fi
Expand Down Expand Up @@ -441,7 +444,9 @@ jobs:
cd ../..
fi
tar -zcf build/html.tgz build/html
rm -rf build/html build/ipynb
# Do not zip so that reviewers can take a look at doc online
# rm -rf build/html build/ipynb
rm -rf build/ipynb
cd ..

- run:
Expand Down
26 changes: 23 additions & 3 deletions doc/python/imshow.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.2'
jupytext_version: 1.4.2
jupytext_version: 1.3.0
kernelspec:
display_name: Python 3
language: python
Expand Down Expand Up @@ -86,6 +86,26 @@ fig = px.imshow(img)
fig.show()
```

### Passing image data as a binary string

... add explanations here about `use_binary_string` and `contrast_rescaling`

```python
import plotly.express as px
import numpy as np
img = np.arange(15**2).reshape((15, 15))
fig = px.imshow(img, use_binary_string=True)
fig.show()
```

```python
import plotly.express as px
import numpy as np
img = np.arange(13**2, dtype=np.uint8).reshape((13, 13))
fig = px.imshow(img, use_binary_string=True, contrast_rescaling='dtype')
fig.show()
```

### Choose the colorscale to display a single-channel image

You can customize the [continuous color scale](/python/colorscales/) just like with any other Plotly Express function:
Expand Down Expand Up @@ -167,7 +187,7 @@ 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).
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-channel 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).

Expand Down Expand Up @@ -308,4 +328,4 @@ fig.show(config={'modeBarButtonsToAdd':['drawline',
```

#### Reference
See https://plotly.com/python/reference/#image for more information and chart attribute options!
See https://plotly.com/python/reference/#image for more information and chart attribute options!
175 changes: 150 additions & 25 deletions packages/javascript/plotlywidget/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/javascript/plotlywidget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"typescript": "~3.1.1"
},
"dependencies": {
"plotly.js": "^1.54.6",
"plotly.js": "https://83625-45646037-gh.circle-artifacts.com/0/plotly.js.tgz",
"@jupyter-widgets/base": "^2.0.0 || ^3.0.0",
"lodash": "^4.17.4"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/python/plotly/codegen/resources/plot-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16979,6 +16979,12 @@
"editType": "none",
"description": "Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves."
},
"source": {
"valType": "string",
"role": "info",
"editType": "calc",
"description": "Specifies the URL of the image to be used. The URL must be accessible from the domain where the plot code is run, and can be either relative or absolute."
},
"z": {
"valType": "data_array",
"role": "data",
Expand Down
Loading