Skip to content

Commit

Permalink
Merge pull request #118 from anntzer/cmap
Browse files Browse the repository at this point in the history
Don't use deprecated matplotlib.cm.get_cmap.
  • Loading branch information
chrishavlin committed Jun 7, 2024
2 parents 219338c + 2f9cbb3 commit 8eba0af
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions yt_idv/opengl_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

from contextlib import ExitStack, contextmanager

import matplotlib.pyplot as plt
import numpy as np
import traitlets
import traittypes
from matplotlib import colormaps as cm
from OpenGL import GL

# Set up a mapping from numbers to names
Expand Down Expand Up @@ -221,7 +221,7 @@ def __init__(self, *args, **kwargs):
@traitlets.validate("colormap_name")
def _validate_name(self, proposal):
try:
cm.get_cmap(proposal["value"])
plt.get_cmap(proposal["value"])
except ValueError:
raise traitlets.TraitError(
"Colormap name needs to be known by" "matplotlib"
Expand All @@ -230,7 +230,7 @@ def _validate_name(self, proposal):

@traitlets.observe("colormap_name")
def _observe_colormap_name(self, change):
cmap = cm.get_cmap(change["new"])
cmap = plt.get_cmap(change["new"])
cmap_vals = np.array(cmap(np.linspace(0, 1, 256)), dtype="f4")
self.data = cmap_vals

Expand Down

0 comments on commit 8eba0af

Please sign in to comment.