Skip to content

Commit

Permalink
post-review
Browse files Browse the repository at this point in the history
  • Loading branch information
Azaya89 committed Dec 9, 2024
1 parent 6f50b09 commit 1393fd1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions hvplot/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
process_derived_datetime_pandas,
_convert_col_names_to_str,
import_datashader,
_mpl_cmap,
is_mpl_cmap,
)
from .utilities import hvplot_extension

Expand Down Expand Up @@ -1486,8 +1486,12 @@ def _process_style(self, kwds, plot_opts):
if 'color' in style_opts:
color = style_opts['color']
elif not isinstance(cmap, dict):
if (isinstance(cmap, str) or _mpl_cmap(cmap)) and any(
c in getattr(cmap, 'name', cmap) for c in categorical_cmaps
# Checks if any of the categorical cmaps matches cmap;
# uses any() instead of `cmap in categorical_cmaps` to handle reversed colormaps (suffixed with `_r`).
# If cmap is LinearSegmentedColormap, get the name attr, else return the str typed cmap.
if (isinstance(cmap, str) or is_mpl_cmap(cmap)) and any(
categorical_cmap in getattr(cmap, 'name', cmap)
for categorical_cmap in categorical_cmaps
):
color = process_cmap(cmap or self._default_cmaps['categorical'], categorical=True)
else:
Expand Down
2 changes: 1 addition & 1 deletion hvplot/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ def relabel_redim(hv_obj, relabel_kwargs, redim_kwargs):
return hv_obj


def _mpl_cmap(obj):
def is_mpl_cmap(obj):
"""Check if the object is a Matplotlib LinearSegmentedColormap."""
if 'matplotlib' not in sys.modules:
return False
Expand Down

0 comments on commit 1393fd1

Please sign in to comment.