@@ -80,12 +80,17 @@ def get_fsl_cmap(cmap=None):
80
80
}
81
81
cdicts ['gray' ] = cdicts ['grey' ]
82
82
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 :]
89
94
90
95
# Create colormap, return
91
96
try :
@@ -94,14 +99,14 @@ def get_fsl_cmap(cmap=None):
94
99
cmap_obj = cmap_obj .reversed ()
95
100
return cmap_obj
96
101
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 ())))
99
104
100
105
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 ):
105
110
"""
106
111
Plots single colorbar.
107
112
@@ -117,6 +122,8 @@ def plot_cbar(vmin=0, vmax=1, dp=2, cmap=None, label=None, nticks=6,
117
122
instance) or fsl colormap string (see get_fsl_cmap function).
118
123
label : str, optional
119
124
Axis label for colorbar
125
+ labelsize : int, optional
126
+ Fontsize for axis label
120
127
nticks : int, optional
121
128
Number of ticks to have on colorbar axis.
122
129
ticksize : int, optional
@@ -129,8 +136,6 @@ def plot_cbar(vmin=0, vmax=1, dp=2, cmap=None, label=None, nticks=6,
129
136
If specified, number of elements must match specified <nticks> value.
130
137
If omitted, labels will be <nticks> evenly spaced values between
131
138
<vmin> and <vmax>, formatted to specified number of dp.
132
- labelsize : int, optional
133
- Fontsize for axis label
134
139
fontcolor : str, rgb / rgba tuple, or hex value, optional
135
140
Font color of all text
136
141
ori : str, optional
@@ -236,7 +241,7 @@ def plot_cbar(vmin=0, vmax=1, dp=2, cmap=None, label=None, nticks=6,
236
241
237
242
# Define label from args
238
243
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 )
240
245
241
246
# Loop through ticks and adjust font size & color
242
247
if ori == 'vertical' :
0 commit comments