Skip to content

Commit ba65990

Browse files
committed
added test with xarray and animations
1 parent 882810f commit ba65990

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/python/plotly/plotly/tests/test_core/test_px/test_imshow.py

+10
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ def test_imshow_xarray(binary_string):
183183
assert np.all(np.array(fig.data[0].x) == np.array(da.coords["dim_cols"]))
184184

185185

186+
def test_imshow_xarray_slicethrough():
187+
img = np.random.random((8, 9, 10))
188+
da = xr.DataArray(img, dims=["dim_0", "dim_1", "dim_2"])
189+
fig = px.imshow(da, animation_frame="dim_0")
190+
# Dimensions are used for axis labels and coordinates
191+
assert fig.layout.xaxis.title.text == "dim_2"
192+
assert fig.layout.yaxis.title.text == "dim_1"
193+
assert np.all(np.array(fig.data[0].x) == np.array(da.coords["dim_2"]))
194+
195+
186196
def test_imshow_labels_and_ranges():
187197
fig = px.imshow([[1, 2], [3, 4], [5, 6]],)
188198
assert fig.layout.xaxis.title.text is None

0 commit comments

Comments
 (0)