Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

facet_col in imshow assumes xarray coordinates are integers #4329

Closed
Karl-Krauth opened this issue Aug 16, 2023 · 1 comment
Closed

facet_col in imshow assumes xarray coordinates are integers #4329

Karl-Krauth opened this issue Aug 16, 2023 · 1 comment

Comments

@Karl-Krauth
Copy link
Contributor

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_
@Karl-Krauth Karl-Krauth changed the title facet_col assumes xarray coordinates are integers facet_col in imshow assumes xarray coordinates are integers Aug 16, 2023
@gvwilson
Copy link
Contributor

Hi - we are tidying up stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for a while, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. If you'd like to submit a PR, we'd be happy to prioritize a review, and if it's a request for tech support, please post in our community forum. Thank you - @gvwilson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants