Skip to content

Commit

Permalink
Merge branch 'hotfix/colormap_update' into main-3.X
Browse files Browse the repository at this point in the history
  • Loading branch information
rparker-creare committed Jun 3, 2024
2 parents 9921582 + 790bc56 commit eebfe28
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions podpac/core/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ def __init__(self, node=None, *args, **kwargs):
@tl.validate("colormap")
def _validate_colormap(self, d):
if isinstance(d["value"], six.string_types):
matplotlib.cm.get_cmap(d["value"])
try:
matplotlib.colormaps[d["value"]]
except AttributeError:
# Need for matplotlib prior to 3.5
matplotlib.cm.get_cmap(d["value"])
if d["value"] and self.enumeration_colors:
raise TypeError("Style can have a colormap or enumeration_colors, but not both")
return d["value"]
Expand Down Expand Up @@ -100,11 +104,19 @@ def full_enumeration_legend(self):
@property
def cmap(self):
if self.colormap:
return matplotlib.cm.get_cmap(self.colormap)
try:
return matplotlib.colormaps[self.colormap]
except AttributeError:
# Need for matplotlib prior to 3.5
return matplotlib.cm.get_cmap(self.colormap)
elif self.enumeration_colors:
return ListedColormap(self.full_enumeration_colors)
else:
return matplotlib.cm.get_cmap("viridis")
try:
return matplotlib.colormaps["viridis"]
except AttributeError:
# Need for matplotlib prior to 3.5
return matplotlib.cm.get_cmap("viridis")

@property
def json(self):
Expand Down

0 comments on commit eebfe28

Please sign in to comment.