comparison m-toolbox/classes/@aoplotter/singlePlots.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % SINGLEPLOT plots each input ao on a seperate figure.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SINGLEPLOT plots each input ao on a seperate figure.
5 %
6 % CALL: hfig = aoplotter.singlePlot(pl);
7 %
8 % OUTPUTS:
9 % hfig - an array of figure handles
10 %
11 % <a href="matlab:utils.helper.displayMethodInfo('aoplotter', 'singlePlots')">Parameters</a>
12 %
13 % VERSION: $Id: singlePlots.m,v 1.2 2011/03/28 12:45:46 hewitson Exp $
14 %
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16 function varargout = singlePlots(varargin)
17
18 % Check if this is a call for parameters
19 if utils.helper.isinfocall(varargin{:})
20 varargout{1} = getInfo(varargin{3});
21 return
22 end
23
24 % Collect input variable names
25 in_names = cell(size(varargin));
26 for ii = 1:nargin,in_names{ii} = inputname(ii);end
27
28 % Get the plotter calling object
29 plotter = utils.helper.collect_objects(varargin(:), 'aoplotter');
30
31 % Collect input plists
32 pl = utils.helper.collect_objects(varargin(:), 'plist');
33 pl = combine(pl, getDefaultPlist);
34
35 hfig = [];
36 for kk=1:numel(plotter.data)
37
38 % get current data object
39 d = plotter.data{kk};
40
41 % Plot each figure on a seperate plot
42 cfig = figure;
43 hls = plot(d.x, d.y);
44
45 % Make axis labels
46 setPlotLabels(plotter, cfig, d);
47
48 % Apply the figure properties from the plotter
49 applyPlotterPreferences(cfig, hls, plotter);
50
51 % Apply procinfo properties
52 applyLineProperties(plotter, hls, d);
53
54 % Apply legend properties
55 applyLegendProperties(plotter, d);
56
57 % Store the handle
58 hfig = [hfig cfig];
59 end
60
61
62 end
63
64 function applyLegendProperties(plotter, d)
65
66 legendFontSize = plotter.legendFontSize;
67 legendLocation = plotter.legendLocation;
68 includeLegend = plotter.includeLegend;
69 includeDescription = plotter.includeDescription;
70
71 if includeLegend
72
73 % make legend
74 name = utils.plottools.label(d.name);
75 desc = utils.plottools.label(d.description);
76
77 if includeDescription && ~isempty(desc)
78 name = [name ': ' desc];
79 end
80
81 [legh,objh,outh,outm] = legend(name, 'Location', legendLocation);
82 set(legh, 'FontSize', legendFontSize);
83 end
84
85 end
86
87 % Apply the properties of the lines. First the values are taken from the
88 % plotter, but if the plotinfo is filled and the override is set, then
89 % those values will be used.
90 function applyLineProperties(plotter, hl, d)
91
92 lineWidth = plotter.lineWidth;
93 linestyle = plotter.lineStyle;
94 markerSize = plotter.markerSize;
95 plotinfoOverride = plotter.plotinfoOverride;
96 colors = plotter.plotcolors;
97 marker = plotter.marker;
98 color = colors{1};
99
100 % -- handle procinfo overrides
101 pinfo = d.plotinfo;
102 % line width
103 if ~isempty(pinfo) && ~isempty(pinfo.find('linewidth')) && plotinfoOverride
104 lineWidth = pinfo.find('linewidth');
105 end
106 % line style
107 if ~isempty(pinfo) && ~isempty(pinfo.find('linestyle')) && plotinfoOverride
108 linestyle = pinfo.find('linestyle');
109 end
110 % marker
111 if ~isempty(pinfo) && ~isempty(pinfo.find('marker')) && plotinfoOverride
112 marker = pinfo.find('marker');
113 end
114 % color
115 if ~isempty(pinfo) && ~isempty(pinfo.find('color')) && plotinfoOverride
116 color = pinfo.find('color');
117 end
118
119 % set color
120 set(hl, 'Color', color)
121 set(hl, 'LineStyle', linestyle);
122 set(hl, 'LineWidth', lineWidth);
123 set(hl, 'MarkerSize', markerSize);
124 set(hl, 'Marker', marker);
125 end
126
127 function setPlotLabels(plotter, cfig, d)
128 hax = get(cfig, 'Children');
129 [xlbl, ylbl, zlbl] = aoplotter.makeAxisLabel(d);
130 h = xlabel(hax, xlbl);
131 setLabelProperties(h, plotter);
132 h = ylabel(hax, ylbl);
133 setLabelProperties(h, plotter);
134 h = zlabel(hax, zlbl);
135 setLabelProperties(h, plotter);
136 end
137
138 function setLabelProperties(h, plotter)
139 set(h, 'FontSize', plotter.labelFontSize);
140 set(h, 'FontName', plotter.axisFontName);
141 end
142
143 function applyPlotterPreferences(hfig, hls, plotter)
144 haxs = get(hfig, 'Children');
145 for kk=1:numel(haxs)
146
147 % Fonts and lines
148 set(haxs(kk), 'FontSize', plotter.axisFontSize);
149 set(haxs(kk), 'FontWeight', plotter.axisFontWeight);
150 set(haxs(kk), 'FontName', plotter.axisFontName);
151 set(haxs(kk), 'LineWidth', plotter.axisLineWidth);
152
153 % Grids
154 set(haxs(kk), 'GridLineStyle', plotter.gridLineStyle);
155 set(haxs(kk), 'MinorGridLineStyle', plotter.minorGridLineStyle);
156
157 if plotter.showXGrid
158 set(haxs(kk), 'XGrid', 'on');
159 end
160 if plotter.showXMinorGrid
161 set(haxs(kk), 'XMinorGrid', 'on');
162 end
163 if plotter.showYGrid
164 set(haxs(kk), 'YGrid', 'on');
165 end
166 if plotter.showYMinorGrid
167 set(haxs(kk), 'YMinorGrid', 'on');
168 end
169
170 end
171
172 end
173
174 %--------------------------------------------------------------------------
175 % Get Info Object
176 %--------------------------------------------------------------------------
177 function ii = getInfo(varargin)
178 if nargin == 1 && strcmpi(varargin{1}, 'None')
179 sets = {};
180 pl = [];
181 else
182 sets = {'Default'};
183 pl = getDefaultPlist;
184 end
185 % Build info object
186 ii = minfo(mfilename, 'plotter', 'ltpda', utils.const.categories.output, '$Id: singlePlots.m,v 1.2 2011/03/28 12:45:46 hewitson Exp $', sets, pl);
187 end
188
189 %--------------------------------------------------------------------------
190 % Get Default Plist
191 %--------------------------------------------------------------------------
192 function pl_default = getDefaultPlist()
193 pl_default = plist();
194
195 end
196
197 % END