annotate util/sparco utils/updateFigure.m @ 221:c1efdd5d6250 luisf_dev

added ompbox_fast as sparse approximation solver, which calls the functions in ompbox using the fastest implementation
author Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk>
date Wed, 11 Apr 2012 16:13:08 +0100
parents 62f20b91d870
children
rev   line source
ivan@77 1 function updateFigure(opts, figTitle, figFilename)
ivan@77 2
ivan@77 3 % Copyright 2008, Ewout van den Berg and Michael P. Friedlander
ivan@77 4 % http://www.cs.ubc.ca/labs/scl/sparco
ivan@77 5 % $Id: updateFigure.m 1040 2008-06-26 20:29:02Z ewout78 $
ivan@77 6
ivan@77 7 % Ensure default values are available
ivan@77 8 opts.linewidth = getOption(opts,'linewidth', []);
ivan@77 9 opts.fontsize = getOption(opts,'fontsize', []);
ivan@77 10 opts.markersize = getOption(opts,'markersize',[]);
ivan@77 11
ivan@77 12 % Output the plots
ivan@77 13 if opts.update
ivan@77 14 % Set the line width, font size and marker size
ivan@77 15 chld = [gca; get(gca,'Children')];
ivan@77 16 lnwd = ones(length(chld),1) * NaN;
ivan@77 17 fnts = ones(length(chld),1) * NaN;
ivan@77 18 mrks = ones(length(chld),1) * NaN;
ivan@77 19 for i=1:length(chld)
ivan@77 20 conf = get(chld(i));
ivan@77 21 if ~isempty(opts.linewidth) && isfield(conf,'LineWidth')
ivan@77 22 lnwd(i) = get(chld(i),'LineWidth');
ivan@77 23 if (lnwd(i) == 0.5) % Default
ivan@77 24 set(chld(i),'Linewidth',opts.linewidth);
ivan@77 25 end
ivan@77 26 end
ivan@77 27 if ~isempty(opts.fontsize) && isfield(conf,'FontSize')
ivan@77 28 fnts(i) = get(chld(i),'FontSize');
ivan@77 29 if (fnts(i) == 10) % Default
ivan@77 30 set(chld(i),'FontSize',opts.fontsize);
ivan@77 31 end
ivan@77 32 end
ivan@77 33 if ~isempty(opts.markersize) && isfield(conf,'MarkerSize')
ivan@77 34 mrks(i) = get(chld(i),'MarkerSize');
ivan@77 35 if (mrks(i) == 6) % Default
ivan@77 36 set(chld(i),'MarkerSize',opts.markersize);
ivan@77 37 end
ivan@77 38 end
ivan@77 39 end
ivan@77 40
ivan@77 41 for i=1:length(opts.figtype)
ivan@77 42 updateFigureType(opts.update, 0, opts.figtype{i}, ...
ivan@77 43 opts.figpath, figTitle, figFilename);
ivan@77 44 end
ivan@77 45
ivan@77 46 % Restore the line-widths, font size
ivan@77 47 for i=1:length(chld)
ivan@77 48 if ~isnan(lnwd(i))
ivan@77 49 set(chld(i),'LineWidth',lnwd(i));
ivan@77 50 end
ivan@77 51 if ~isnan(fnts(i))
ivan@77 52 set(chld(i),'FontSize',fnts(i));
ivan@77 53 end
ivan@77 54 if ~isnan(mrks(i))
ivan@77 55 set(chld(i),'MarkerSize',mrks(i));
ivan@77 56 end
ivan@77 57 end
ivan@77 58
ivan@77 59 end
ivan@77 60
ivan@77 61 % Show the plot
ivan@77 62 if opts.show
ivan@77 63 updateFigureType(0,opts.show,'','',figTitle,'');
ivan@77 64 end
ivan@77 65
ivan@77 66
ivan@77 67
ivan@77 68 function updateFigureType(update,show,figtype,figpath,figTitle,figFilename)
ivan@77 69 filename = [figpath,figFilename];
ivan@77 70
ivan@77 71 switch lower(figtype)
ivan@77 72 case {'pdf'}
ivan@77 73 cmdPostprocess = sprintf('!pdfcrop %s.pdf %s.pdf >& /dev/null', ...
ivan@77 74 filename, filename);
ivan@77 75 otherwise
ivan@77 76 cmdPostprocess = [];
ivan@77 77 end
ivan@77 78
ivan@77 79 [figtype,figext] = getFigureExt(figtype);
ivan@77 80
ivan@77 81 % Print the figure for output (without title)
ivan@77 82 if update
ivan@77 83 evalc(sprintf('print -d%s %s.%s;', figtype, filename, figext));
ivan@77 84
ivan@77 85 if ~isempty(cmdPostprocess)
ivan@77 86 eval(cmdPostprocess);
ivan@77 87 end
ivan@77 88 end
ivan@77 89
ivan@77 90 % Add title if needed
ivan@77 91 if show
ivan@77 92 title(figTitle);
ivan@77 93 end