1 %> @ingroup graphicsapi
3 %> @brief Generates a colormap from an integer vector of classes.
5 %> @brief Functions to draw plots and images based on values and axis data from a @ref sovalues
object
8 %> 2D Structure array with fields varying
11 %> 2-element Array of axisdata objects
12 ax = raxisdata.empty();
18 %> Draws single plot with many lines
19 %> @param name =
'rates'.
'rates'/
'times1'/
'times2'/
'times3' etc
20 %> @param flag_legend =1. (Legends will be ax(2).legends)
21 %> @param ylimits =(automatically calculated by MATLAB)
22 %> @param xticks =(taken from the @ref ax property)
23 %> @param xticklabels=(taken from the @ref ax property)
24 function draw_plot(o, name, flag_legend, ylimits, xticks, xticklabels, star_ii)
25 if nargin < 2 || isempty(name)
29 if nargin < 3 || isempty(flag_legend)
34 if nargin >= 4 && ~isempty(ylimits)
38 if nargin < 5 || isempty(xticks)
39 xticks = o.ax(1).values;
42 if nargin < 6 || isempty(xticklabels)
43 xticklabels = o.ax(1).ticks;
47 if nargin < 7 || isempty(star_ii)
52 [nfe, nar, fold] = size(D);
56 if length(nfs) > nfe % This is a hack because I was saving results wrongly!
65 X = reshape(D(:, j, :), [nfe, fold]); % matrix [nfe]x[number of folds in cross-validation]
68 ci(1:2, m) =
confint(X(m, :))'; % Calculates confidence intervals
69 me(m) = mean(X(m, :));
79 hl(j) = plot(nfs(:), me, 'Color',
find_color(j), 'LineStyle',
find_linestyle(j), 'Linewidth',
scaled(3), 'Marker',
find_marker(j), 'MarkerSize',
find_marker_size(j));
81 disp('tentando descobrir a merda no FRANK-PC');
87 plot(nfs(star_ii(j)), me(star_ii(j)), 'p', 'LineWidth', scaled(2.5), 'MarkerSize', scaled(25), 'Color',
find_color(j));
95 xlabel(o.ax(1).label);
96 ylabel(labeldict(name));
98 legend(hl, o.ax(2).legends);
103 set(gca, 'XTick', xticks);
104 set(gca, 'XTickLabel', xticklabels);
109 % set(gca, 'Position', [0.0661 0.0927 0.8953 0.8382]); % Empirical
114 %> Draws a single figure with several subplots.
116 %> Each subplot corresponds to a different architecture.
118 %> @param name ='rates'. 'rates'/'times1'/'times2'/'times3' etc
119 %> @param ylimits =(automatically calculated by MATLAB for each individual subplot)
120 %> @param xticks =(taken from the @ref ax property)
121 %> @param xticklabels=(taken from the @ref ax property)
122 function draw_subplots(o, name, ylimits, xticks, xticklabels, star_ii)
124 if nargin < 2 || isempty(name)
129 [nfe, nar, fold] = size(D);
131 nfs = o.ax(1).values;
132 if length(nfs) > nfe % This is a hack because I was saving results wrongly!
138 if nargin >= 3 && ~isempty(ylimits)
142 if nargin < 4 || isempty(xticks)
146 if nargin < 5 || isempty(xticklabels)
147 xticklabels = o.ax(1).ticks;
151 if nargin < 6 || isempty(star_ii)
157 % Determines number of plot rows and columns
158 w = ceil(sqrt(nar)); % number of columns (Width)
159 h = ceil(nar/w); % number of rows (Height)
161 % Spacings and margins are sensitive to the number of plot rows
164 hwref = max(w/4, h/3);
176 subw = (1-XSPACING*(w-1)-MLEF-MRIG)/w;
177 subh = (1-YSPACING*(h-1)-MTOP-MBOT)/h;
181 y0 = MBOT+(subh+YSPACING)*(h-1);
192 subplot('Position', [x0, y0, subw, subh]); %h, w, k);
194 X = reshape(D(:, k, :), [nfe, fold]); % matrix [nfe]x[number of folds in cross-validation]
197 ci(1:2, m) =
confint(X(m, :))'; % Calculates confidence intervals
198 me(m) = mean(X(m, :));
206 plot(nfs, me, 'Color',
find_color(k), 'LineStyle',
find_linestyle(k), 'Linewidth', scaled(3), 'Marker',
find_marker(k), 'MarkerSize',
find_marker_size(k));
211 plot(nfs(star_ii(k)), me(star_ii(k)), 'p', 'LineWidth', scaled(2.5), 'MarkerSize', scaled(25), 'Color',
find_color(k));
214 % % % % % % if i == h
215 % % % % % % xlabel('Number of features');
216 % % % % % set(gca, 'xtick', xticks);
218 % % % % % % ylabel('');
223 set(gca, 'XTick', xticks);
224 set(gca, 'XTickLabel', xticklabels);
232 title(o.ax(2).legends{k},
'FontWeight',
'bold');
236 x0 = x0+(subw+XSPACING);
238 y0 = y0-(subh+YSPACING);
241 global FONT FONTSIZE;
244 % If there is one plot only, uses MATLAB
's default x- and
246 xlabel(o.ax(1).label);
247 ylabel(labeldict(name));
248 set(gca, 'Position
', [0.0661 0.0927 0.8953 0.8382]); % Empirical
250 % Vertical label (e.g. "Classification rate (%)")
251 subplot('Position
', [0, 0, MLEF*.8, 1]);
253 text('Position
', [0.5, 0.5, 0], ...
255 'HorizontalAlignment
', 'center
', ...
256 'VerticalAlignment
', 'middle
', ...
257 'FontName
', FONT, ...
258 'FontSize
', scaled(FONTSIZE), ...
259 'String
', labeldict(name));
261 % Vertical label (e.g. "Classification rate (%)")
262 subplot('Position
', [MLEF, 0, 1-MLEF, MBOT*0.8]);
264 text('Position
', [0.5, 0.5, 0], ...
266 'HorizontalAlignment
', 'center
', ...
267 'VerticalAlignment
', 'middle
', ...
268 'FontName
', FONT, ...
269 'FontSize
', scaled(FONTSIZE), ...
270 'String
', o.ax(1).label);
277 %> Draws each value as an image pixel
280 %> @arg it may use the whole colormap range (don't specify the @c clim parameter), or
281 %> @arg make the colormap span the range specificed by @c clim (and the values will probably be contained within a subrange
282 %> thereof). This
case is useful
for when you want to draw several images and
compare them
using the same
"color scale"
284 %> @param name =
'rates'.
'rates'/
'times1'/
'times2'/
'times3' etc
285 %> @param star_ij (optional) Row and Column of the "best", to put a STAR on. If not specified, no star is drawn
286 %> @param clim =[] see description above
287 %> @param flag_logtake =0 Whether to take logarithm of values (useful
288 %> for SVM time images
289 function o =
draw_image(o, name, star_ij, clim, flag_logtake, flag_transpose)
291 if nargin < 2 || isempty(name)
296 if nargin < 3 || isempty(star_ij)
301 if nargin < 4 || isempty(clim)
305 if nargin < 5 || isempty(flag_logtake)
309 if nargin < 6 || isempty(flag_transpose)
322 [ny, nx] = size(o.values);
325 [nx, ny] = size(o.values);
340 set(gca, 'CLim', clim);
341 image(xx, yy, Z', 'CDataMapping', '
scaled');
342 set(gca, 'CLim', clim);
350 xlabel(o.ax(a1).label);
351 ylabel(o.ax(a2).label);
353 set(gca, 'XTick', xx, 'YTick', yy, 'XTickLabel', o.ax(a1).ticks, 'YTickLabel', o.ax(a2).ticks);
357 % THis is disabled because one these "ticks" are put, they cannot be removed by xtick([])
358 % rotateticklabel(gca, 90);
361 plot3(star_ij(a1), star_ij(a2), 0.1, 'pk', 'LineWidth', scaled(2), 'MarkerSize', scaled(15));
366 make_box(); % This is image, makebox maybe not
373 %> Mounts a matrix containing the averages of a field within the "values" property specified by the "name" parameter
374 function y = get_y(o, name)
375 [ni, nj] = size(o.values);
379 y(i, j) = mean(o.values(i, j).(name));
385 %> Mounts a matrix containing the values of a field within the "values" property specified by the "name" parameter
386 function Y = get_Y(o, name)
387 [ni, nj] = size(o.values);
391 Y(i, j, :) = o.values(i, j).(name); %
#ok<*AGROW>
function compare(in o1, in o2)
function find_marker(in i)
function find_color(in i)
function maximize_window(in h, in aspectratio, in normalizedsize)
function decimate_ticks(in flags, in maxs)
function draw_image(in Y, in height, in direction)
function find_marker_size(in i)
function find_linestyle(in i)
function draw_hachure2(in xaxis, in intervals, in color)
function confint(in x, in perc)