|
1 | 1 | import plotly.graph_objs as go
|
2 | 2 | from _plotly_utils.basevalidators import ColorscaleValidator
|
3 |
| -from ._core import apply_default_cascade |
| 3 | +from ._core import apply_default_cascade, init_figure |
4 | 4 | from io import BytesIO
|
5 | 5 | import base64
|
6 | 6 | from .imshow_utils import rescale_intensity, _integer_ranges, _integer_types
|
@@ -133,6 +133,9 @@ def imshow(
|
133 | 133 | labels={},
|
134 | 134 | x=None,
|
135 | 135 | y=None,
|
| 136 | + animation_frame=False, |
| 137 | + facet_col=False, |
| 138 | + facet_col_wrap=None, |
136 | 139 | color_continuous_scale=None,
|
137 | 140 | color_continuous_midpoint=None,
|
138 | 141 | range_color=None,
|
@@ -277,6 +280,14 @@ def imshow(
|
277 | 280 | args = locals()
|
278 | 281 | apply_default_cascade(args)
|
279 | 282 | labels = labels.copy()
|
| 283 | + if facet_col: |
| 284 | + nslices = img.shape[-1] |
| 285 | + ncols = facet_col_wrap |
| 286 | + nrows = nslices / ncols |
| 287 | + else: |
| 288 | + nrows = 1 |
| 289 | + ncols = 1 |
| 290 | + fig = init_figure(args, 'xy', [], nrows, ncols, [], []) |
280 | 291 | # ----- Define x and y, set labels if img is an xarray -------------------
|
281 | 292 | if xarray_imported and isinstance(img, xarray.DataArray):
|
282 | 293 | if binary_string:
|
@@ -449,7 +460,8 @@ def imshow(
|
449 | 460 | layout_patch["title_text"] = args["title"]
|
450 | 461 | elif args["template"].layout.margin.t is None:
|
451 | 462 | layout_patch["margin"] = {"t": 60}
|
452 |
| - fig = go.Figure(data=trace, layout=layout) |
| 463 | + fig.add_trace(trace) |
| 464 | + fig.update_layout(layout) |
453 | 465 | fig.update_layout(layout_patch)
|
454 | 466 | # Hover name, z or color
|
455 | 467 | if binary_string and rescale_image and not np.all(img == img_rescaled):
|
|
0 commit comments