Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated matplotlib get_cmap() #185

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ephyviewer/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def on_automatic_color(self, cmap_name = None):
cmap_name = str(self.combo_cmap.currentText())
n = np.sum(self.selected)
if n==0: return
cmap = matplotlib.cm.get_cmap(cmap_name , n)
cmap = matplotlib.colormaps[cmap_name].resampled(n)

self.viewer.by_channel_params.blockSignals(True)
for i, c in enumerate(np.nonzero(self.selected)[0]):
Expand Down
2 changes: 1 addition & 1 deletion ephyviewer/datasource/epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(self, epoch=None, possible_labels=[], color_labels=None, channel_na
# TODO: colors should be managed directly by EpochEncoder
if color_labels is None:
n = len(self.possible_labels)
cmap = matplotlib.cm.get_cmap('Dark2' , n)
cmap = matplotlib.colormaps['Dark2'].resampled(n)
color_labels = [ matplotlib.colors.ColorConverter().to_rgb(cmap(i)) for i in range(n)]
color_labels = (np.array(color_labels)*255).astype(int)
color_labels = color_labels.tolist()
Expand Down
2 changes: 1 addition & 1 deletion ephyviewer/datasource/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(self, signals, sample_rate, t_start, scatter_indexes, scatter_chann
if self.scatter_colors is None:
self.scatter_colors = {}
n = len(self._labels)
colors = matplotlib.cm.get_cmap('Accent', n)
colors = matplotlib.colormaps['Accent'].resampled(n)
for i,k in enumerate(self._labels):
self.scatter_colors[k] = matplotlib.colors.to_hex(colors(i))

Expand Down
2 changes: 1 addition & 1 deletion ephyviewer/spectrogramviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def create_grid(self):
def change_color_scale(self):
N = 512
cmap_name = self.params['colormap']
cmap = matplotlib.cm.get_cmap(cmap_name , N)
cmap = matplotlib.colormaps[cmap_name].resampled(N)

lut = []
for i in range(N):
Expand Down
2 changes: 1 addition & 1 deletion ephyviewer/timefreqviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def initialize_time_freq(self):
def change_color_scale(self):
N = 512
cmap_name = self.params['colormap']
cmap = matplotlib.cm.get_cmap(cmap_name , N)
cmap = matplotlib.colormaps[cmap_name].resampled(N)

lut = []
for i in range(N):
Expand Down
Loading