Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Replace deprecated/removed matplotlib.cm.LUTSIZE #515

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

Merged
merged 1 commit into from
Sep 21, 2023
Merged
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
13 changes: 7 additions & 6 deletions nipy/labs/viz_tools/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
try:
from matplotlib import cm as _cm
from matplotlib import colors as _colors
from matplotlib import rcParams as _rc
except ImportError:
skip_if_running_nose('Could not import matplotlib')

Expand Down Expand Up @@ -109,7 +110,7 @@ def alpha_cmap(color, name=''):
(red, green, blue, 1.),
]
cmap = _colors.LinearSegmentedColormap.from_list(
'%s_transparent' % name, cmapspec, _cm.LUTSIZE)
'%s_transparent' % name, cmapspec, _rc['image.lut'])
cmap._init()
cmap._lut[:, -1] = _np.linspace(.5, 1.0, cmap._lut.shape[0])
cmap._lut[-1, -1] = 0
Expand Down Expand Up @@ -159,17 +160,17 @@ def alpha_cmap(color, name=''):
_cmapspec = _cmaps_data[_cmapname]
if 'red' in _cmapspec:
_cmap_d[_cmapname] = _colors.LinearSegmentedColormap(
_cmapname, _cmapspec, _cm.LUTSIZE)
_cmapname, _cmapspec, _rc['image.lut'])
_cmap_d[_cmapname_r] = _cmap_d[_cmapname].reversed(name=_cmapname_r)
else:
_revspec = list(reversed(_cmapspec))
if len(_revspec[0]) == 2: # e.g., (1, (1.0, 0.0, 1.0))
_revspec = [(1.0 - a, b) for a, b in _revspec]

_cmap_d[_cmapname] = _colors.LinearSegmentedColormap.from_list(
_cmapname, _cmapspec, _cm.LUTSIZE)
_cmapname, _cmapspec, _rc['image.lut'])
_cmap_d[_cmapname_r] = _colors.LinearSegmentedColormap.from_list(
_cmapname_r, _revspec, _cm.LUTSIZE)
_cmapname_r, _revspec, _rc['image.lut'])

################################################################################
# A few transparent colormaps
Expand Down Expand Up @@ -207,7 +208,7 @@ def dim_cmap(cmap, factor=.3, to_white=True):
return _colors.LinearSegmentedColormap(
'%s_dimmed' % cmap.name,
cdict,
_cm.LUTSIZE)
_rc['image.lut'])


def replace_inside(outer_cmap, inner_cmap, vmin, vmax):
Expand Down Expand Up @@ -267,6 +268,6 @@ def replace_inside(outer_cmap, inner_cmap, vmin, vmax):
return _colors.LinearSegmentedColormap(
'%s_inside_%s' % (inner_cmap.name, outer_cmap.name),
cdict,
_cm.LUTSIZE)
_rc['image.lut'])