Skip to content

Commit df8c013

Browse files
committed
Update docs to include facet_row
1 parent a071788 commit df8c013

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

doc/python/imshow.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,11 @@ for compression_level in range(0, 9):
400400
fig.show()
401401
```
402402

403-
### Exploring 3-D images, timeseries and sequences of images with `facet_col`
403+
### Exploring 3-D and 4-D images with `facet_col` and `facet_row`
404404

405-
*Introduced in plotly 4.14*
405+
*`facet_col` introduced in plotly 4.14, `facet_row` introduced in plotly 6.7.0*
406406

407-
For three-dimensional image datasets, obtained for example by MRI or CT in medical imaging, one can explore the dataset by representing its different planes as facets. The `facet_col` argument specifies along which axis the image is sliced through to make the facets. With `facet_col_wrap`, one can set the maximum number of columns. For image datasets passed as xarrays, it is also possible to specify the axis by its name (label), thus passing a string to `facet_col`.
407+
For three-dimensional image datasets, obtained for example by MRI or CT in medical imaging, one can explore the dataset by representing its different planes as facets. The `facet_col` argument specifies along which axis the image is sliced through to make column facets, while `facet_row` specifies the axis for row facets. Using both together creates a grid of subplots for 4-D datasets. With `facet_col_wrap`, one can set the maximum number of columns (ignored when `facet_row` is set). For image datasets passed as xarrays, it is also possible to specify the axis by its name (label), thus passing a string to `facet_col` or `facet_row`.
408408

409409
It is recommended to use `binary_string=True` for facetted plots of images in order to keep a small figure size and a short rendering time.
410410

@@ -436,6 +436,18 @@ for i, sigma in enumerate(sigmas):
436436
fig.show()
437437
```
438438

439+
The `facet_row` argument slices the image along a different axis to arrange facets vertically. When both `facet_row` and `facet_col` are used together, a grid of subplots is created from a 4-D dataset.
440+
441+
```python
442+
import plotly.express as px
443+
from skimage import io
444+
data = io.imread("https://github.com/scikit-image/skimage-tutorials/raw/main/images/cells.tif")
445+
data = data.reshape((6, 10, 256, 256))[:3, :2]
446+
fig = px.imshow(data, facet_row=0, facet_col=1, binary_string=True,
447+
labels={'facet_row':'group', 'facet_col':'slice'})
448+
fig.show()
449+
```
450+
439451
### Exploring 3-D images and timeseries with `animation_frame`
440452

441453
*Introduced in plotly 4.14*
@@ -479,6 +491,17 @@ fig = px.imshow(data, animation_frame=0, facet_col=1, binary_string=True)
479491
fig.show()
480492
```
481493

494+
With `facet_row`, it is also possible to view 5-dimensional datasets by combining `animation_frame`, `facet_row`, and `facet_col`.
495+
496+
```python
497+
import plotly.express as px
498+
from skimage import io
499+
data = io.imread("https://github.com/scikit-image/skimage-tutorials/raw/main/images/cells.tif")
500+
data = data.reshape((5, 3, 4, 256, 256))
501+
fig = px.imshow(data, animation_frame=0, facet_row=1, facet_col=2, binary_string=True)
502+
fig.show()
503+
```
504+
482505
#### Reference
483506

484507
See [function reference for `px.(imshow)`](https://plotly.com/python-api-reference/generated/plotly.express.imshow) or https://plotly.com/python/reference/image/ for more information and chart attribute options!

0 commit comments

Comments
 (0)