-
Notifications
You must be signed in to change notification settings - Fork 1
/
coolwarm.m
302 lines (297 loc) · 4.57 KB
/
coolwarm.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
function map = coolwarm(m)
%COOLWARM cool-warm color map
% COOLWARM(M) returns an M-by-3 matrix containing a colormap with cool-to-warm
% colors, as commonly used in Paraview.
% COOLWARM, by itself, is the same length as the current colormap.
%
% For example, to reset the colormap of the current figure:
%
% colormap(coolwarm)
%
% Colormap is based on the colors used by the freeware program Paraview.
% The color table used here is CoolWarmUChar33.csv, from
% http://www.sandia.gov/~kmorel/documents/ColorMaps/
% Reference: Moreland, Kenneth, 2009, Diverging Color Maps for Scientific
% Visualization, in Proceedings of the 5th International Symposium on
% Visual Computing.
% The Matlab code is after haxby.m by Kelsey Jordahl, Marymount Manhattan
% College.
%
% See also HSV, GRAY, PINK, COOL, BONE, COPPER, FLAG, HOT
% COLORMAP, RGBPLOT, HAXBY.
% Mark Brandon
% Yale University
% Time-stamp: <Aug 20 2012>
%% Check inputs
narginchk(0,1);
if nargin == 1
validateattributes(m,{'numeric'},{'numel',1});
end
%% Begin Function
if nargin < 1, m = size(get(gcf,'colormap'),1); end
c=[59 76 192;
60 78 194;
61 80 195;
62 81 197;
63 83 198;
64 85 200;
66 87 201;
67 88 203;
68 90 204;
69 92 206;
70 93 207;
71 95 209;
73 97 210;
74 99 211;
75 100 213;
76 102 214;
77 104 215;
79 105 217;
80 107 218;
81 109 219;
82 110 221;
84 112 222;
85 114 223;
86 115 224;
87 117 225;
89 119 226;
90 120 228;
91 122 229;
93 123 230;
94 125 231;
95 127 232;
96 128 233;
98 130 234;
99 131 235;
100 133 236;
102 135 237;
103 136 238;
104 138 239;
106 139 239;
107 141 240;
108 142 241;
110 144 242;
111 145 243;
112 147 243;
114 148 244;
115 150 245;
116 151 246;
118 153 246;
119 154 247;
120 156 247;
122 157 248;
123 158 249;
124 160 249;
126 161 250;
127 163 250;
129 164 251;
130 165 251;
131 167 252;
133 168 252;
134 169 252;
135 171 253;
137 172 253;
138 173 253;
140 174 254;
141 176 254;
142 177 254;
144 178 254;
145 179 254;
147 181 255;
148 182 255;
149 183 255;
151 184 255;
152 185 255;
153 186 255;
155 187 255;
156 188 255;
158 190 255;
159 191 255;
160 192 255;
162 193 255;
163 194 255;
164 195 254;
166 196 254;
167 197 254;
168 198 254;
170 199 253;
171 199 253;
172 200 253;
174 201 253;
175 202 252;
176 203 252;
178 204 251;
179 205 251;
180 205 251;
182 206 250;
183 207 250;
184 208 249;
185 208 248;
187 209 248;
188 210 247;
189 210 247;
190 211 246;
192 212 245;
193 212 245;
194 213 244;
195 213 243;
197 214 243;
198 214 242;
199 215 241;
200 215 240;
201 216 239;
203 216 238;
204 217 238;
205 217 237;
206 217 236;
207 218 235;
208 218 234;
209 219 233;
210 219 232;
211 219 231;
213 219 230;
214 220 229;
215 220 228;
216 220 227;
217 220 225;
218 220 224;
219 220 223;
220 221 222;
221 221 221;
222 220 219;
223 220 218;
224 219 216;
225 219 215;
226 218 214;
227 218 212;
228 217 211;
229 216 209;
230 216 208;
231 215 206;
232 215 205;
232 214 203;
233 213 202;
234 212 200;
235 212 199;
236 211 197;
236 210 196;
237 209 194;
238 209 193;
238 208 191;
239 207 190;
240 206 188;
240 205 187;
241 204 185;
241 203 184;
242 202 182;
242 201 181;
243 200 179;
243 199 178;
244 198 176;
244 197 174;
245 196 173;
245 195 171;
245 194 170;
245 193 168;
246 192 167;
246 191 165;
246 190 163;
246 188 162;
247 187 160;
247 186 159;
247 185 157;
247 184 156;
247 182 154;
247 181 152;
247 180 151;
247 178 149;
247 177 148;
247 176 146;
247 174 145;
247 173 143;
247 172 141;
247 170 140;
247 169 138;
247 167 137;
247 166 135;
246 164 134;
246 163 132;
246 161 131;
246 160 129;
245 158 127;
245 157 126;
245 155 124;
244 154 123;
244 152 121;
244 151 120;
243 149 118;
243 147 117;
242 146 115;
242 144 114;
241 142 112;
241 141 111;
240 139 109;
240 137 108;
239 136 106;
238 134 105;
238 132 103;
237 130 102;
236 129 100;
236 127 99;
235 125 97;
234 123 96;
233 121 95;
233 120 93;
232 118 92;
231 116 90;
230 114 89;
229 112 88;
228 110 86;
227 108 85;
227 106 83;
226 104 82;
225 102 81;
224 100 79;
223 98 78;
222 96 77;
221 94 75;
220 92 74;
218 90 73;
217 88 71;
216 86 70;
215 84 69;
214 82 67;
213 80 66;
212 78 65;
210 75 64;
209 73 62;
208 71 61;
207 69 60;
205 66 59;
204 64 57;
203 62 56;
202 59 55;
200 57 54;
199 54 53;
198 51 52;
196 49 50;
195 46 49;
193 43 48;
192 40 47;
190 37 46;
189 34 45;
188 30 44;
186 26 43;
185 22 41;
183 17 40;
181 11 39;
180 4 38];
%... Interpolate get requested size for color table
pp=1:(m-1)/(size(c,1)-1):m;
r=interp1(pp,c(:,1),1:m);
g=interp1(pp,c(:,2),1:m);
b=interp1(pp,c(:,3),1:m);
%... Normalize to range [0,1], and divide again by maximum value
% to correct for round-off errors associated with the interpolation.
map=[r' g' b']/255;
map = map/max(map(:));