|
1 | 1 | import plotly.graph_objs as go |
2 | 2 | from _plotly_utils.basevalidators import ColorscaleValidator |
3 | 3 | from ._core import apply_default_cascade |
4 | | -import numpy as np # is it fine to depend on np here? |
| 4 | +import numpy as np |
5 | 5 |
|
6 | 6 | _float_types = [] |
7 | 7 |
|
@@ -107,7 +107,8 @@ def imshow( |
107 | 107 |
|
108 | 108 | range_color : list of two numbers |
109 | 109 | If provided, overrides auto-scaling on the continuous color scale, including |
110 | | - overriding `color_continuous_midpoint`. |
| 110 | + overriding `color_continuous_midpoint`. Also overrides zmin and zmax. Used only |
| 111 | + for single-channel images. |
111 | 112 |
|
112 | 113 | title : str |
113 | 114 | The figure title. |
@@ -147,14 +148,18 @@ def imshow( |
147 | 148 |
|
148 | 149 | # For 2d data, use Heatmap trace |
149 | 150 | if img.ndim == 2: |
150 | | - trace = go.Heatmap(z=img, zmin=zmin, zmax=zmax, coloraxis="coloraxis1") |
| 151 | + trace = go.Heatmap(z=img, coloraxis="coloraxis1") |
151 | 152 | autorange = True if origin == "lower" else "reversed" |
152 | 153 | layout = dict( |
153 | 154 | xaxis=dict(scaleanchor="y", constrain="domain"), |
154 | 155 | yaxis=dict(autorange=autorange, constrain="domain"), |
155 | 156 | ) |
156 | 157 | colorscale_validator = ColorscaleValidator("colorscale", "imshow") |
157 | | - range_color = range_color or [None, None] |
| 158 | + if zmin is not None and zmax is None: |
| 159 | + zmax = img.max() |
| 160 | + if zmax is not None and zmin is None: |
| 161 | + zmin = img.min() |
| 162 | + range_color = range_color or [zmin, zmax] |
158 | 163 | layout["coloraxis1"] = dict( |
159 | 164 | colorscale=colorscale_validator.validate_coerce( |
160 | 165 | args["color_continuous_scale"] |
|
0 commit comments