Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Add facet_row support to px.imshow#5445

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
FBumann wants to merge3 commits intoplotly:main
base:main
Choose a base branch
Loading
fromFBumann:main

Conversation

@FBumann
Copy link

@FBumannFBumann commentedDec 6, 2025
edited
Loading

Summary

This PR addsfacet_row support toplotly.express.imshow, enabling visualization of 4D and 5D data by faceting along both row and column dimensions.

Closes#4108

Motivation

Currently,px.imshow only supportsfacet_col for creating faceted plots, limiting users to visualizing 3D data (with one facet dimension). Many scientific and
engineering use cases require visualizing 4D tensor data (e.g., full factorial experimental designs in ML and biological sciences). This PR enables users to use both
facet_row andfacet_col simultaneously, along withanimation_frame, to visualize up to 5D datasets.

Changes

plotly/express/_imshow.py

  • Addedfacet_row parameter to the function signature
  • Updated docstring to document the new parameter
  • Updated slice dimension calculations to handle bothfacet_row andfacet_col
  • Updated xarray handling to extractfacet_row dimension labels
  • Updated array reshaping to handle the additional dimension
  • Updated figure building to generate row labels and place traces correctly
  • Note:facet_col_wrap is ignored whenfacet_row is set (consistent with other px functions)

tests/test_optional/test_px/test_imshow.py

  • Addedtest_facet_row: Tests facet_row with numpy arrays
  • Addedtest_facet_row_and_col: Tests using both facet_row and facet_col together
  • Addedtest_animation_facet_row_and_col: Tests animation + facet_row + facet_col
  • Addedtest_imshow_xarray_facet_row: Tests facet_row with xarray
  • Addedtest_imshow_xarray_facet_row_and_col: Tests both facets with xarray

Example Usage

importplotly.expressaspx# Prepare data for multi dimensional usagedf=px.data.tips()cols= ['smoker','sex','time','day','size']pivot=df.groupby(cols)['total_bill'].mean().reset_index()da=pivot.set_index(cols).to_xarray()['total_bill']# 4D data: visualize with facet_row and facet_colfig1=px.imshow(da.sum('day'),facet_row="smoker",facet_col="sex")fig1.show()# Also works with numpyfig2=px.imshow(da.sum('day').values,facet_row=0,facet_col=1)fig2.show()# 5D data: animation + facet_row + facet_colfig3=px.imshow(da,facet_row="smoker",facet_col="sex",animation_frame='day')fig3.show()

@FBumannFBumann changed the titleeat: Add facet_row support to px.imshowfeat: Add facet_row support to px.imshowDec 6, 2025
@FBumannFBumann marked this pull request as ready for reviewDecember 6, 2025 15:21
@FBumann
Copy link
Author

Build fails are unrelated to changes afaik.#5442

@emilykl
Copy link
Contributor

Build fails are unrelated to changes afaik.#5442

@FBumann You're right,#5442 has been merged so the docs build should be fixed onmain; you can update this branch and run CI again.

@FBumann
Copy link
Author

@emilykl Ready for review

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

@emilyklemilykl

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

add facet_row support in px.imshow

2 participants

@FBumann@emilykl

[8]ページ先頭

©2009-2025 Movatter.jp