From 9fcc3790dc5cb50713d4a58cc3c6de58be0820b0 Mon Sep 17 00:00:00 2001 From: Jordan Landers Date: Sat, 1 Jun 2024 21:39:01 -0700 Subject: [PATCH 1/2] another get_cmap fix --- pyleoclim/utils/plotting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyleoclim/utils/plotting.py b/pyleoclim/utils/plotting.py index 9f247fdb..dd123a15 100644 --- a/pyleoclim/utils/plotting.py +++ b/pyleoclim/utils/plotting.py @@ -1424,7 +1424,7 @@ def keep_center_colormap(cmap, vmin, vmax, center=0): dv = max(-vmin, vmax) * 2 N = int(256 * dv / (vmax - vmin)) - cont_map = cm.get_cmap(cmap, N) + cont_map = plt.get_cmap(cmap, N) newcolors = cont_map(np.linspace(0, 1, N)) beg = int((dv / 2 + vmin) * N / dv) end = N - int((dv / 2 - vmax) * N / dv) From 8a8fbb3535f16d074619e468e4d0d38d87ab3db8 Mon Sep 17 00:00:00 2001 From: Jordan Landers Date: Sat, 1 Jun 2024 22:05:38 -0700 Subject: [PATCH 2/2] scrap keep_center_colormap ex --- pyleoclim/utils/plotting.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/pyleoclim/utils/plotting.py b/pyleoclim/utils/plotting.py index dd123a15..81c362a8 100644 --- a/pyleoclim/utils/plotting.py +++ b/pyleoclim/utils/plotting.py @@ -1395,24 +1395,6 @@ def keep_center_colormap(cmap, vmin, vmax, center=0): the centered value across the data. This adjusted colormap can then be used for data visualization tasks where maintaining a perceptual 'zero' or central reference point is important. - - Examples - -------- - - .. jupyter-execute:: - - import matplotlib.pyplot as plt - import pyleoclim as pyleo - - new_colormap = pyleo.utils.plotting.keep_center_colormap('RdBu', vmin=-300, vmax=300, center=0) - plt.imshow(data, cmap=new_colormap) - plt.colorbar() - - This will create and use a colormap where the value 0 is centered, and the colormap is adjusted - to symmetrically represent deviations from this center, making it suitable for displaying anomalies - or differences from a baseline in a visually balanced manner. - - """ vmin = vmin - center