Skip to content

Commit 8b1ba94

Browse files
author
davidmwatson
committed
Minor bug + doc fixes
1 parent 1bd0bc9 commit 8b1ba94

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

Diff for: plotting.py

+20-15
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,17 @@ def get_fsl_cmap(cmap=None):
8080
}
8181
cdicts['gray'] = cdicts['grey']
8282

83-
# Handle reverse colourmap names
84-
if cmap.endswith('_r'):
85-
reverse = True
86-
cmap = cmap[:-2]
87-
else:
88-
reverse = False
83+
if cmap is not None:
84+
# Handle reverse colourmap names
85+
if cmap.endswith('_r'):
86+
reverse = True
87+
cmap = cmap[:-2]
88+
else:
89+
reverse = False
90+
91+
# Handle fsl- prefix
92+
if cmap.startswith('fsl-'):
93+
cmap = cmap[4:]
8994

9095
# Create colormap, return
9196
try:
@@ -94,14 +99,14 @@ def get_fsl_cmap(cmap=None):
9499
cmap_obj = cmap_obj.reversed()
95100
return cmap_obj
96101
except KeyError:
97-
raise Exception('cmap must be one of: ' \
98-
+ ', '.join(sorted(cdicts.keys())))
102+
raise KeyError('cmap must be one of: fsl-' \
103+
+ ', fsl-'.join(sorted(cdicts.keys())))
99104

100105

101-
def plot_cbar(vmin=0, vmax=1, dp=2, cmap=None, label=None, nticks=6,
102-
ticksize=24, tickpos=None, ticklabels=None, font='sans-serif',
103-
fontsize=24, fontcolor='black', ori='vertical', figsize=None,
104-
segmented=False, segment_interval=1):
106+
def plot_cbar(vmin=0, vmax=1, dp=2, cmap=None, label=None, labelsize=32,
107+
nticks=6, ticksize=24, tickpos=None, ticklabels=None,
108+
font='sans-serif', fontcolor='black', ori='vertical',
109+
figsize=None, segmented=False, segment_interval=1):
105110
"""
106111
Plots single colorbar.
107112
@@ -117,6 +122,8 @@ def plot_cbar(vmin=0, vmax=1, dp=2, cmap=None, label=None, nticks=6,
117122
instance) or fsl colormap string (see get_fsl_cmap function).
118123
label : str, optional
119124
Axis label for colorbar
125+
labelsize : int, optional
126+
Fontsize for axis label
120127
nticks : int, optional
121128
Number of ticks to have on colorbar axis.
122129
ticksize : int, optional
@@ -129,8 +136,6 @@ def plot_cbar(vmin=0, vmax=1, dp=2, cmap=None, label=None, nticks=6,
129136
If specified, number of elements must match specified <nticks> value.
130137
If omitted, labels will be <nticks> evenly spaced values between
131138
<vmin> and <vmax>, formatted to specified number of dp.
132-
labelsize : int, optional
133-
Fontsize for axis label
134139
fontcolor : str, rgb / rgba tuple, or hex value, optional
135140
Font color of all text
136141
ori : str, optional
@@ -236,7 +241,7 @@ def plot_cbar(vmin=0, vmax=1, dp=2, cmap=None, label=None, nticks=6,
236241

237242
# Define label from args
238243
if label is not None:
239-
cb.set_label(label, size=fontsize, color=fontcolor, family=font)
244+
cb.set_label(label, size=labelsize, color=fontcolor, family=font)
240245

241246
# Loop through ticks and adjust font size & color
242247
if ori == 'vertical':

0 commit comments

Comments
 (0)