Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- Fix concurrent first access to lazily initialized graph object properties, which could raise `ValueError("Invalid value")` [[#3441](https://github.com/plotly/plotly.py/issues/3441)], with thanks to @hb1915 for the contribution!
- Fix `px.sunburst`, `px.treemap` and `px.icicle` listing sectors in a different order on every run when `path` is used with a Polars DataFrame; sectors now follow their order of first appearance for all dataframe backends [[#5765](https://github.com/plotly/plotly.py/issues/5765)], with thanks to @Irahan2 for the contribution!
- Fix `px.imshow` ignoring `zmin`/`zmax` when only one of them is passed and the image contains NaN values, since the missing bound was computed as NaN [[#4299](https://github.com/plotly/plotly.py/issues/4299)], with thanks to @MohammadHijjawi97 for the contribution!


## [7.1.0] - 2026-09-15
Expand Down
4 changes: 2 additions & 2 deletions plotly/express/_imshow.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ def imshow(
if contrast_rescaling == "minmax":
# When using binary_string and minmax we need to set zmin and zmax to rescale the image
if (zmin is not None or binary_string) and zmax is None:
zmax = img.max()
zmax = np.nanmax(img)
if (zmax is not None or binary_string) and zmin is None:
zmin = img.min()
zmin = np.nanmin(img)
else:
# For uint8 data and infer we let zmin and zmax to be None if passed as None
if zmax is None and img.dtype != np.uint8:
Expand Down
11 changes: 11 additions & 0 deletions tests/test_optional/test_px/test_imshow.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,17 @@ def test_zmin_zmax_range_color():
assert fig.layout.coloraxis.cmax == 0.8


def test_zmin_zmax_nan_data():
# NaN values should be ignored when inferring the missing bound
img = np.array([[1.0, 2.0], [3.0, np_nan()]])
fig = px.imshow(img, zmax=2)
assert fig.layout.coloraxis.cmin == 1.0
assert fig.layout.coloraxis.cmax == 2.0
fig = px.imshow(img, zmin=2)
assert fig.layout.coloraxis.cmin == 2.0
assert fig.layout.coloraxis.cmax == 3.0


def test_zmin_zmax_range_color_source():
img = img_gray / 100.0
fig1 = px.imshow(img, zmin=0.2, zmax=0.8, binary_string=True)
Expand Down