IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
data_draw_means.m
Go to the documentation of this file.
1 %>@ingroup datasettools
2 %>@file
3 %>@brief Draws class means
4 
5 %> @param data Dataset
6 %> @param peakdetector (optional) @ref peakdetector object. If passed, will used it to draw peaks.
7 %> @param flag_pieces=1 Whether to use plot_curve_pieces() or normal plot
8 %>
9 %> @sa irdata, peakdetector
10 function data = data_draw_means(data, peakdetector, flag_pieces)
11 
12 flag_pd = nargin >= 2 && ~isempty(peakdetector);
13 
14 cm = classes2colormap(data.classes, 1);
15 
16 ucl = unique(data.classes);
17 
18 hs = [];
19 
20 ymin = Inf;
21 ymax = -Inf;
22 for i = 1:numel(ucl)
23  ytemp = mean(data.X(data.classes == ucl(i), :), 1);
24  ymin = min([ymin, ytemp]);
25  ymax = max([ymax, ytemp]);
26  aa = {data.fea_x, ytemp, 'Color', cm(i, :), 'LineWidth', scaled(3)};
27  if flag_pieces
28  htemp = plot_curve_pieces(aa{:});
29  hs(end+1) = htemp{1};
30  else
31  hs(end+1) = plot(aa{:});
32  end;
33 
34  hold on;
35 
36  if flag_pd
37  peakd = peakdetector.boot(data.fea_x, ytemp);
38  idxs_peaks = peakd.use([], ytemp);
39  draw_peaks(data.fea_x, ytemp, idxs_peaks);
40  end;
41 
42 end;
43 hl = legend(hs, data_get_legend(data));
44 
45 ylabel([data.yname, iif(~isempty(data.yunit), sprintf(' (%s)', data.yunit), '')]);
46 format_xaxis(data);
47 format_ylim([ymin, ymax]);
48 format_frank([], [], hl);
function draw_peaks(in x, in y, in indexes, in flag_text, in color, in marker, in markersize)
function classes2colormap(in y, in flag_skip)
Dataset class.
Definition: irdata.m:30
Peak Detector.
Definition: peakdetector.m:6
function data_get_legend(in data)
function boot(in o, in x, in y)
function plot_curve_pieces(in x, in y, in varargin)
function scaled(in i)
function data_draw_means(in data, in peakdetector, in flag_pieces)
function iif(in cond, in x1, in x2)
function format_ylim(in yy)
function format_frank(in F, in scale, in handles)
function format_xaxis(in par)