Skip to content

Commit

Permalink
another get_cmap fix (#564)
Browse files Browse the repository at this point in the history
* another get_cmap fix

* scrap keep_center_colormap ex
  • Loading branch information
jordanplanders authored Jun 2, 2024
1 parent 398bc12 commit f87f764
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions pyleoclim/utils/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1424,7 +1406,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)
Expand Down

0 comments on commit f87f764

Please sign in to comment.