|
30 | 30 | from ..plot import GenericElementPlot, GenericOverlayPlot |
31 | 31 | from ..util import color_intervals, dim_range_key, process_cmap |
32 | 32 | from .plot import MPLPlot, mpl_rc_context |
33 | | -from .util import MPL_VERSION, EqHistNormalize, validate, wrap_formatter |
| 33 | +from .util import MPL_GE_3_11_0, MPL_VERSION, EqHistNormalize, validate, wrap_formatter |
34 | 34 |
|
35 | 35 |
|
36 | 36 | class ElementPlot(GenericElementPlot, MPLPlot): |
@@ -587,7 +587,7 @@ def _set_axis_ticks(self, axis, ticks, log=False, rotation=0): |
587 | 587 | elif isinstance(ticks, (list, tuple)): |
588 | 588 | labels = None |
589 | 589 | if all(isinstance(t, tuple) for t in ticks): |
590 | | - ticks, labels = zip(*ticks, strict=None) |
| 590 | + ticks, labels = zip(*ticks, strict=True) |
591 | 591 | axis.set_ticks(ticks) |
592 | 592 | if labels: |
593 | 593 | axis.set_ticklabels(labels) |
@@ -1211,13 +1211,25 @@ def _norm_kwargs(self, element, ranges, opts, vdim, values=None, prefix=""): |
1211 | 1211 | ) |
1212 | 1212 | cmap = mpl_colors.ListedColormap(palette) |
1213 | 1213 |
|
1214 | | - cmap = copy.copy(cmap) |
1215 | | - if "max" in colors: |
1216 | | - cmap.set_over(**colors["max"]) |
1217 | | - if "min" in colors: |
1218 | | - cmap.set_under(**colors["min"]) |
1219 | | - if "NaN" in colors: |
1220 | | - cmap.set_bad(**colors["NaN"]) |
| 1214 | + if MPL_GE_3_11_0: |
| 1215 | + |
| 1216 | + def _dict_to_rgba(name): |
| 1217 | + dct = colors.get(name) |
| 1218 | + if dct is None: |
| 1219 | + return None |
| 1220 | + return mpl_colors.to_rgba(dct["color"], alpha=dct.get("alpha")) |
| 1221 | + |
| 1222 | + cmap = cmap.with_extremes( |
| 1223 | + over=_dict_to_rgba("max"), under=_dict_to_rgba("min"), bad=_dict_to_rgba("NaN") |
| 1224 | + ) |
| 1225 | + else: |
| 1226 | + cmap = copy.copy(cmap) |
| 1227 | + if "max" in colors: |
| 1228 | + cmap.set_over(**colors["max"]) |
| 1229 | + if "min" in colors: |
| 1230 | + cmap.set_under(**colors["min"]) |
| 1231 | + if "NaN" in colors: |
| 1232 | + cmap.set_bad(**colors["NaN"]) |
1221 | 1233 | opts[prefix + "cmap"] = cmap |
1222 | 1234 |
|
1223 | 1235 |
|
|
0 commit comments