Closed
Description
Minimal example:
arr = xr.DataArray(np.random.randn(2, 3, 3), dims=("string", "1", "2"), coords={"string": ["A", "B"]})
px.imshow(arr, facet_col="string")
Which prints the following error message:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[54], line 2
1 arr = xr.DataArray(np.random.randn(2, 3, 3), dims=("string", "1", "2"), coords={"string": ["A", "B"]})
----> 2 px.imshow(arr, facet_col="string")
File ~/.bin/mambaforge/lib/python3.10/site-packages/plotly/express/_imshow.py:544, in imshow(img, zmin, zmax, origin, labels, x, y, animation_frame, facet_col, facet_col_wrap, facet_col_spacing, facet_row_spacing, color_continuous_scale, color_continuous_midpoint, range_color, title, template, width, height, aspect, contrast_rescaling, binary_string, binary_backend, binary_compression_level, binary_format, text_auto)
540 if facet_col is not None:
541 slice_label = (
542 "facet_col" if labels.get("facet_col") is None else labels["facet_col"]
543 )
--> 544 col_labels = ["%s=%d" % (slice_label, i) for i in facet_slices]
545 fig = init_figure(args, "xy", [], nrows, ncols, col_labels, [])
546 for attr_name in ["height", "width"]:
File ~/.bin/mambaforge/lib/python3.10/site-packages/plotly/express/_imshow.py:544, in <listcomp>(.0)
540 if facet_col is not None:
541 slice_label = (
542 "facet_col" if labels.get("facet_col") is None else labels["facet_col"]
543 )
--> 544 col_labels = ["%s=%d" % (slice_label, i) for i in facet_slices]
545 fig = init_figure(args, "xy", [], nrows, ncols, col_labels, [])
546 for attr_name in ["height", "width"]:
TypeError: %d format: a real number is required, not numpy.str_
Metadata
Metadata
Assignees
Labels
No labels