Skip to content

Commit 57fd8a8

Browse files
committed
Improve colormap handling and default in add_data
1 parent 1ce7e3d commit 57fd8a8

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

surfer/viz.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from . import utils, io
1717
from .config import config
18-
from .utils import Surface, verbose, _get_subjects_dir
18+
from .utils import Surface, verbose, create_color_lut, _get_subjects_dir
1919

2020

2121
import logging
@@ -757,7 +757,7 @@ def add_overlay(self, source, min=None, max=None, sign="abs", name=None,
757757
self._toggle_render(True, views)
758758

759759
def add_data(self, array, min=None, max=None, thresh=None,
760-
colormap="blue-red", alpha=1,
760+
colormap="RdBu_r", alpha=1,
761761
vertices=None, smoothing_steps=20, time=None,
762762
time_label="time index=%d", colorbar=True,
763763
hemi=None):
@@ -788,10 +788,10 @@ def add_data(self, array, min=None, max=None, thresh=None,
788788
max value in colormap (uses real max if None)
789789
thresh : None or float
790790
if not None, values below thresh will not be visible
791-
colormap : str | array [256x4]
792-
name of Mayavi colormap to use, or a custom look up table (a 256x4
793-
array, with the columns representing RGBA (red, green, blue, alpha)
794-
coded with integers going from 0 to 255).
791+
colormap : string, list of colors, or array
792+
name of matplotlib colormap to use, a list of matplotlib colors,
793+
or a custom look up table (an n x 4 array coded with RBGA values
794+
between 0 and 255).
795795
alpha : float in [0, 1]
796796
alpha level to control opacity
797797
vertices : numpy array
@@ -841,16 +841,9 @@ def add_data(self, array, min=None, max=None, thresh=None,
841841
# Copy and byteswap to deal with Mayavi bug
842842
mlab_plot = _prepare_data(array_plot)
843843

844-
# process colormap argument
845-
if isinstance(colormap, basestring):
846-
lut = None
847-
else:
848-
lut = np.asarray(colormap)
849-
if lut.shape != (256, 4):
850-
err = ("colormap argument must be mayavi colormap (string) or"
851-
" look up table (array of shape (256, 4))")
852-
raise ValueError(err)
853-
colormap = "blue-red"
844+
# Process colormap argument into a lut
845+
lut = create_color_lut(colormap)
846+
colormap = "Greys"
854847

855848
data = dict(array=array, smoothing_steps=smoothing_steps,
856849
fmin=min, fmid=(min + max) / 2, fmax=max,

0 commit comments

Comments
 (0)