From 4a4b6582e5291618bf9d814823aac64f58b3c14a Mon Sep 17 00:00:00 2001 From: danibene <34680344+danibene@users.noreply.github.com> Date: Sun, 19 May 2024 11:43:07 -0400 Subject: [PATCH] use "resampled" https://github.com/matplotlib/matplotlib/issues/20853 --- neurokit2/complexity/entropy_phase.py | 2 +- neurokit2/hrv/hrv_nonlinear.py | 2 +- neurokit2/microstates/microstates_plot.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/neurokit2/complexity/entropy_phase.py b/neurokit2/complexity/entropy_phase.py index 7867ad8edd..8a54bb5adc 100644 --- a/neurokit2/complexity/entropy_phase.py +++ b/neurokit2/complexity/entropy_phase.py @@ -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): diff --git a/neurokit2/hrv/hrv_nonlinear.py b/neurokit2/hrv/hrv_nonlinear.py index b20e7ea711..cf7c6058a6 100644 --- a/neurokit2/hrv/hrv_nonlinear.py +++ b/neurokit2/hrv/hrv_nonlinear.py @@ -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 = plt.get_cmap("Blues")(np.linspace(0, 1, 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") diff --git a/neurokit2/microstates/microstates_plot.py b/neurokit2/microstates/microstates_plot.py index e550cf9e11..6b6c6ba322 100644 --- a/neurokit2/microstates/microstates_plot.py +++ b/neurokit2/microstates/microstates_plot.py @@ -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.get_cmap("plasma")(np.linspace(0, 1, 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