1 %> @brief converts colors to a map to be used by @ref
draw_stacked.m
3 %> @ingroup graphicsapi conversion
5 %> @param colors =(
default colors). Can be a cell of 2 elements, 3 elements or 4 elements.
6 %> @arg 2 elements: {informative color | [] |
"colormap name", non-informative color}
7 %> @arg 3 elements: {[] |
"colormap name", non-informative color start, non-informative color end}
8 %> @arg 4 elements: {informative color start, informative color end, non-informative color start, non-informative color end}
9 %> @note the empty cases (
"[]") mean that
find_color_stackedhist() will be used; the 3-element case only accepts an empty first element
12 %> @param no_informative
13 %> @return <code>[cm, leg_cm, leg_la]</code> @cm is a color map with @c no_hists rows; @c leg_cm is a color map with repeating colors grouped;
14 %> @c leg_la are the legend labels that correspond to @c leg_cm
15 function [cm, leg_cm, leg_la] =
colors2map(colors, no_hists, no_informative)
17 % Makes colormap and legends simultaneously
18 if numel(colors) == 3 || isempty(colors{1}) || ischar(colors{1})
19 % note that here, colors may be 2- or 3-element
22 for i = 1:no_informative
26 cm = feval(colors{1}, no_informative);
30 leg_la = arrayfun(@
int2ord, 1:no_informative,
'UniformOutput', 0);
33 flag_gradient = numel(colors) > 2;
34 if no_informative < no_hists
36 cm = [cm; ones(no_hists-no_informative, 1)*colors{2}];
37 leg_cm = [leg_cm; colors{2}];
38 leg_la = [leg_la,
iif(no_informative < no_hists-1, sprintf(
'%s-%s',
int2ord(no_informative+1),
int2ord(no_hists)),
int2ord(no_hists))];
41 cm(no_informative+1:no_hists, i) = linspace(colors{2}(i), colors{3}(i), no_hists-no_informative);
44 leg_la = arrayfun(@
int2ord, 1:no_hists,
'UniformOutput', 0);
49 % Note that here, colors may be 2- or 4-element
51 flag_gradient = numel(colors) > 2;
55 cm = ones(no_informative, 1)*colors{1};
56 if no_informative < no_hists
57 cm = [cm; ones(no_hists-no_informative, 1)*colors{2}];
60 leg_cm(1, :) = colors{1};
62 if no_informative < no_hists
63 leg_cm(2, :) = colors{2};
64 leg_la{2} =
iif(no_informative < no_hists-1, sprintf(
'%s-%s',
int2ord(no_informative+1),
int2ord(no_hists)),
int2ord(no_hists));
71 cm(1:no_informative, i) = linspace(colors{1}(i), colors{2}(i), no_informative);
74 if no_informative < no_hists
76 cm(no_informative+1:no_hists, i) = linspace(colors{3}(i), colors{4}(i), no_hists-no_informative);
81 leg_la = arrayfun(@
int2ord, 1:no_hists,
'UniformOutput', 0);
function colors2map(in colors, in no_hists, in no_informative)
function iif(in cond, in x1, in x2)
function find_color_stackedhist(in i)
function draw_stacked(in x, in histss, in no_informative, in colors, in x_hint, in hint, in peakd, in flag_trace_minalt, in flag_draw_peaks, in flag_print_peaks, in flag_text)