Skip to content

Commit afb5c4d

Browse files
committed
use init_figure from main px core
1 parent c0247d2 commit afb5c4d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

packages/python/plotly/plotly/express/_imshow.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import plotly.graph_objs as go
22
from _plotly_utils.basevalidators import ColorscaleValidator
3-
from ._core import apply_default_cascade
3+
from ._core import apply_default_cascade, init_figure
44
from io import BytesIO
55
import base64
66
from .imshow_utils import rescale_intensity, _integer_ranges, _integer_types
@@ -133,6 +133,9 @@ def imshow(
133133
labels={},
134134
x=None,
135135
y=None,
136+
animation_frame=False,
137+
facet_col=False,
138+
facet_col_wrap=None,
136139
color_continuous_scale=None,
137140
color_continuous_midpoint=None,
138141
range_color=None,
@@ -277,6 +280,14 @@ def imshow(
277280
args = locals()
278281
apply_default_cascade(args)
279282
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, [], [])
280291
# ----- Define x and y, set labels if img is an xarray -------------------
281292
if xarray_imported and isinstance(img, xarray.DataArray):
282293
if binary_string:
@@ -449,7 +460,8 @@ def imshow(
449460
layout_patch["title_text"] = args["title"]
450461
elif args["template"].layout.margin.t is None:
451462
layout_patch["margin"] = {"t": 60}
452-
fig = go.Figure(data=trace, layout=layout)
463+
fig.add_trace(trace)
464+
fig.update_layout(layout)
453465
fig.update_layout(layout_patch)
454466
# Hover name, z or color
455467
if binary_string and rescale_image and not np.all(img == img_rescaled):

0 commit comments

Comments
 (0)