IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
format_xaxis.m
Go to the documentation of this file.
1 %>@ingroup graphicsapi
2 %>@file
3 %>@brief Format x-axis to nice range and reversed
4 %
5 %> @param par May be either a vector or an irdata object. If the former, takes the values at the extremities of the vector to use as the x-axis limits; if the latter, takes the x-axis limits from the @a fea_x property and uses the @a xlabel property to set the x-label.
6 function format_xaxis(par)
7 
8 if exist('par', 'var')
9  if isa(par, 'irdata')
10  if ~isempty(par.fea_names)
11  nf = numel(par.fea_x);
12  MAXTICKS = 16; % Maximum 12 ticks
13  nins = nf/MAXTICKS;
14  if nins > 1
15  ii = round(1:nins:nf);
16  else
17  ii = 1:nf;
18  end;
19 
20  set(gca, 'XTick', par.fea_x(ii));
21  set(gca, 'XTickLabel', par.fea_names(ii));
22  end;
23  end;
24 
25  if isobject(par) || isstruct(par)
26  ff = fields(par);
27  if ismember('L_fea_x', ff) % fcon_linear
28  x1 = par.L_fea_x(1);
29  x2 = par.L_fea_x(end);
30  elseif ismember('fea_x', ff) % irdata and others
31  x1 = par.fea_x(1);
32  x2 = par.fea_x(end);
33  else
34  irerror('parameter nas neither L_fea_x nor fea_x property!');
35  end;
36 
37  if ismember('xname', ff)
38  s = par.xname;
39  if ismember('xunit', ff)
40  if ~isempty(par.xunit);
41  s = [s ' (' par.xunit ')'];
42  end;
43  end;
44  xlabel(s);
45  end;
46  else % Assumes numeric vector
47  x1 = par(1);
48  x2 = par(end);
49  end;
50 else
51  % Default OPUS range
52  x1 = 1801.47;
53  x2 = 898.81;
54 end;
55 
56 A = .99;
57 if x1 == x2
58  xabs = abs(x1);
59  v_xlim = [x1+xabs*.9, x1+xabs*1.1];
60 elseif x1 > x2
61  set(gca, 'XDir', 'reverse');
62  v_xlim = [x2*A, x1+(x2*(1-A))];
63 else
64  v_xlim = [x1*A, x2+(x1*(1-A))];
65 end;
66 
67 % Xlim
68 set(gca, 'XLim', v_xlim);
Feature Construction - Linear Transformations base class.
Definition: fcon_linear.m:2
function irerror(in s)
Dataset class.
Definition: irdata.m:30
Analysis Session (AS) base class.
Definition: as.m:6
function format_xaxis(in par)