3 %> @brief Draws stacked histograms
5 %> Uses BAR(...,
'stacked') to do the job
7 %> @param x [nf] x-axis values.
8 %> @param histss [no_hists][nf] hits matrix
9 %> @param no_informative Number of histograms that are considered "informative"
11 %> @param x_hint =[]. [nf] x-axis values. If not passed or empty, uses @a x if @a hint is passed.
12 %> @param hint [nf] "hint" curve that helps the reading of the loadings. If not passed or empty, no hint curve is drawn.
13 %> @param peakd =[] Peak Detector
object.
14 %> @param flag_trace_minalt =~isempty(peakd) Whether to draw the threshold line. Only works if the peak detector is passed.
15 %> @param flag_draw_peaks =~isempty(peakd) Whether to mark the detected peaks in the figure.
16 %> @param flag_print_peaks =~isempty(peakd) Whether to print detected peaks on the command line window.
17 %> @param flag_text =0 Whether to write peak wavenumbers besize the "x"'s
18 function
draw_stacked(x, histss, no_informative, colors, x_hint, hint, peakd, flag_trace_minalt, flag_draw_peaks, flag_print_peaks, flag_text)
20 if ~exist('x_hint', 'var') || isempty(x_hint)
23 if ~exist('hint', 'var') || isempty(hint)
26 if ~exist('colors', 'var') || isempty(colors)
27 % colors = {[.8, 0, 0], [.9, .2, .2], .7*[1, 1, 1], .85*[1, 1, 1]};
28 colors = {[], .85*[1, 1, 1]};
31 no_colors = numel(colors);
32 if no_colors == 3 && ~isempty(colors{1})
33 irerror(
'If the number of colors passed is 3, the first element must be empty!');
36 if ~exist(
'no_informative',
'var') || isempty(no_informative)
39 if ~exist('peakd', 'var') || isempty(peakd)
42 if ~exist('flag_trace_minalt', 'var') || isempty(flag_trace_minalt)
43 flag_trace_minalt = ~isempty(peakd);
45 if ~exist('flag_draw_peaks', 'var') || isempty(flag_draw_peaks)
46 flag_draw_peaks = ~isempty(peakd);
48 if ~exist('flag_print_peaks', 'var') || isempty(flag_print_peaks)
49 flag_print_peaks = ~isempty(peakd);
52 if ~exist('flag_text', 'var') || isempty(flag_text)
56 no_hists = size(histss, 1);
57 no_informative = min(no_informative, no_hists);
59 [cm, leg_cm, leg_la] =
colors2map(colors, no_hists, no_informative);
64 ymax = max(sum(histss, 1));
73 bar(x, histss', 'stacked', 'LineStyle', 'none');
87 flag_bother_peaks = ~isempty(peakd) && (flag_print_peaks || flag_draw_peaks);
89 y = sum(histss(1:no_informative, :), 1);
90 peakd = peakd.boot(x, y);
91 idxs_peaks = peakd.use([], y);
98 fprintf('---------------- Peaks %s -----------------\n', '');
102 % Plots "minimum altitude" line
116 set(gca, 'Ylim', [0, ceil(ymax*1.025)]);
121 %===========================================================================================================================================
123 h = plot(-1000, 0, 'LineStyle', 'none', 'Marker', 's', 'MarkerSize', markersize, 'Color', color, 'MarkerFaceColor', color);
function draw_peaks(in x, in y, in indexes, in flag_text, in color, in marker, in markersize)
function colors2map(in colors, in no_hists, in no_informative)
function print_peaks(in x, in idxs_peaks)
function draw_hint_curve(in x, in y, in color)
function draw_threshold_line(in x, in y, in width, in color)
function plot_marker(in color, in markersize)
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)