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

[Fix] Syntax to get colormap #991

Merged
merged 5 commits into from
May 20, 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
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def find_version():
"use_edit_page_button": True,
"logo_only": True,
"show_toc_level": 1,
"navigation_with_keys": False,
}


Expand Down
2 changes: 1 addition & 1 deletion neurokit2/complexity/entropy_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def entropy_phase(signal, delay=1, k=4, show=False, **kwargs):
Tx = Tx.astype(bool)
Ys = np.sin(angles) * limx * np.sqrt(2)
Xs = np.cos(angles) * limx * np.sqrt(2)
colors = plt.get_cmap("jet")(np.linspace(0, 1, k))
colors = plt.get_cmap("jet").resampled(k)

plt.figure()
for i in range(k):
Expand Down
3 changes: 1 addition & 2 deletions neurokit2/events/events_plot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
import matplotlib.cm
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -127,7 +126,7 @@ def events_plot(events, signal=None, color="red", linestyle="--"):
else:
# Convert color and style to list
if isinstance(color, str):
color_map = matplotlib.cm.get_cmap("rainbow")
color_map = plt.get_cmap("rainbow")
color = color_map(np.linspace(0, 1, num=len(events)))
if isinstance(linestyle, str):
linestyle = np.full(len(events), linestyle)
Expand Down
2 changes: 1 addition & 1 deletion neurokit2/hrv/hrv_nonlinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def _hrv_nonlinear_show(rri, rri_time=None, rri_missing=False, out={}, ax=None,
kernel = scipy.stats.gaussian_kde(values)
f = np.reshape(kernel(positions).T, xx.shape)

cmap = matplotlib.cm.get_cmap("Blues", 10)
cmap = plt.get_cmap("Blues").resampled(10)
ax.contourf(xx, yy, f, cmap=cmap)
ax.imshow(np.rot90(f), extent=[ax1_min, ax1_max, ax2_min, ax2_max], aspect="auto")

Expand Down
2 changes: 1 addition & 1 deletion neurokit2/microstates/microstates_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def microstates_plot(microstates, segmentation=None, gfp=None, info=None, epoch=
if epoch is None:
epoch = (0, len(gfp))

cmap = plt.cm.get_cmap("plasma", n)
cmap = plt.get_cmap("plasma").resampled(n)
# Plot the GFP line above the area
ax["GFP"].plot(
times[epoch[0] : epoch[1]], gfp[epoch[0] : epoch[1]], color="black", linewidth=0.5
Expand Down
3 changes: 1 addition & 2 deletions neurokit2/signal/signal_power.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
import matplotlib.cm
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -193,7 +192,7 @@ def _signal_power_instant_plot(psd, out, frequency_band, ax=None):
labels = [f"{i[1]}-{i[2]} Hz" for i in labels]

# Get cmap
cmap = matplotlib.cm.get_cmap("Set1")
cmap = plt.get_cmap("Set1")
colors = cmap.colors
colors = (
colors[3],
Expand Down
Loading