IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
draw_peaks.m
Go to the documentation of this file.
1 %>@ingroup graphicsapi
2 %> @file
3 %> @brief Draws peaks
4 %
5 %> @param x
6 %> @param y
7 %> @param indexes
8 %> @param flag_text
9 %> @param color =black
10 %> @param marker =x
11 %< @param markersize =scaled(10)
12 function draw_peaks(x, y, indexes, flag_text, color, marker, markersize)
13 fig_assert();
14 global FONTSIZE FONT;
15 
16 if ~exist('flag_text', 'var')
17  flag_text = 1;
18 end;
19 if nargin < 5 || isempty(color)
20  color = [0, 0, 0];
21 end;
22 if nargin < 6 || isempty(marker)
23  marker = 'x';
24 end;
25 if nargin < 7 || isempty(markersize)
26  markersize = scaled(10);
27 end;
28 
29 scale = max(abs(y));
30 % offset = 0.025*scale;
31 
32 y(y == Inf) = max(y(y ~= Inf));
33 
34 x_peaks = x(indexes);
35 y_peaks = y(indexes);
36 
37 
38 for i = 1:length(x_peaks)
39  plot(x_peaks(i), y_peaks(i), 'Color', color, 'Marker', marker, 'MarkerSize', markersize, 'LineWidth', scaled(3));
40  hold on;
41  offset = 0.025*scale;
42  if y_peaks(i) < 0
43  offset = -offset;
44  end;
45 
46  if flag_text
47  text(x_peaks(i), y_peaks(i)+offset, sprintf('%.0f', x(indexes(i))), 'FontName', FONT, 'FontSize', FONTSIZE*scaled(0.75));
48  end;
49 end;
function draw_peaks(in x, in y, in indexes, in flag_text, in color, in marker, in markersize)
function scaled(in i)
function fig_assert()