File data_analysis/@meta_ev/plot_cuts.m changed (mode: 100644) (index 30cd24e..73591df) |
... |
... |
function plot_cuts(meta, plot_type, tracepairs_ind, par_ind, par_vals, varargin) |
29 |
29 |
colororder = []; |
colororder = []; |
30 |
30 |
legend_postfix = ''; |
legend_postfix = ''; |
31 |
31 |
legend_location = 'Best'; |
legend_location = 'Best'; |
|
32 |
|
legend_number_parser = @num2eng; |
|
33 |
|
legend_title_maxlength = inf; |
32 |
34 |
for k=1:2:length(varargin) |
for k=1:2:length(varargin) |
33 |
35 |
switch lower(varargin{k}) |
switch lower(varargin{k}) |
34 |
36 |
case {'x_scale','xscale'} |
case {'x_scale','xscale'} |
|
... |
... |
function plot_cuts(meta, plot_type, tracepairs_ind, par_ind, par_vals, varargin) |
49 |
51 |
colororder = varargin{k+1}; |
colororder = varargin{k+1}; |
50 |
52 |
case {'legend_postfix','legendpostfix'} |
case {'legend_postfix','legendpostfix'} |
51 |
53 |
legend_postfix = varargin{k+1}; |
legend_postfix = varargin{k+1}; |
|
54 |
|
case {'legend_numberformat','legendnumberformat'} |
|
55 |
|
switch varargin{k+1} |
|
56 |
|
case 'engineering' |
|
57 |
|
% default: leave num2eng |
|
58 |
|
case {'float', 'plain'} |
|
59 |
|
legend_number_parser = @num2str; |
|
60 |
|
case {'short', 'round'} |
|
61 |
|
legend_number_parser = @(num)num2str(round(100*num)/100); |
|
62 |
|
otherwise |
|
63 |
|
error(['Unrecognized option ', varargin{k+1}, ' for "legend_numberformat".']); |
|
64 |
|
end |
52 |
65 |
case {'legend_position','legendposition','legend_location','legendlocation'} |
case {'legend_position','legendposition','legend_location','legendlocation'} |
53 |
66 |
legend_location = varargin{k+1}; |
legend_location = varargin{k+1}; |
|
67 |
|
case {'legend_title_maxlength', 'legendtitlemaxlength'} |
|
68 |
|
legend_title_maxlength = varargin{k+1}; |
54 |
69 |
otherwise |
otherwise |
55 |
70 |
error(['unrecognized varargin-argument: ', varargin{k}]); |
error(['unrecognized varargin-argument: ', varargin{k}]); |
56 |
71 |
end |
end |
|
... |
... |
function plot_cuts(meta, plot_type, tracepairs_ind, par_ind, par_vals, varargin) |
75 |
90 |
|
|
76 |
91 |
end |
end |
77 |
92 |
if isempty(legend_postfix) |
if isempty(legend_postfix) |
78 |
|
legend_parser = @(num) num2eng(num); |
|
|
93 |
|
legend_parser = @(num) legend_number_parser(num); |
79 |
94 |
else |
else |
80 |
|
legend_parser = @(num) [num2eng(num), ' (', legend_postfix,')']; |
|
|
95 |
|
legend_parser = @(num) [legend_number_parser(num), ' (', legend_postfix,')']; |
81 |
96 |
end |
end |
82 |
97 |
cut_labels = arrayfun(legend_parser, unique(meta_filtered.params{par_ind}),... |
cut_labels = arrayfun(legend_parser, unique(meta_filtered.params{par_ind}),... |
83 |
98 |
'UniformOutput', false); |
'UniformOutput', false); |
|
... |
... |
function plot_cuts(meta, plot_type, tracepairs_ind, par_ind, par_vals, varargin) |
87 |
102 |
meta_ev.xylims(x_lims, y_lims); |
meta_ev.xylims(x_lims, y_lims); |
88 |
103 |
leg = legend('Location', legend_location); |
leg = legend('Location', legend_location); |
89 |
104 |
legtitle = get(leg,'title'); |
legtitle = get(leg,'title'); |
90 |
|
set(legtitle,'string', sentence_case(meta_filtered.param_names{par_ind}),... |
|
|
105 |
|
if legend_title_maxlength==inf |
|
106 |
|
title_str = sentence_case(meta_filtered.param_names{par_ind}); |
|
107 |
|
else |
|
108 |
|
title_str = linewrap(sentence_case(meta_filtered.param_names{par_ind}),... |
|
109 |
|
legend_title_maxlength); |
|
110 |
|
end |
|
111 |
|
set(legtitle,'string', title_str,... |
91 |
112 |
'interpreter', 'latex','FontSize',11); |
'interpreter', 'latex','FontSize',11); |
92 |
113 |
set(leg, 'Color', 'w', 'FontWeight', 'normal',... |
set(leg, 'Color', 'w', 'FontWeight', 'normal',... |
93 |
114 |
'LineWidth', 1, 'Interpreter', 'latex','FontSize',11); |
'LineWidth', 1, 'Interpreter', 'latex','FontSize',11); |
File misc/3rdparty/linewrap.m added (mode: 100644) (index 0000000..dde94b4) |
|
1 |
|
function c = linewrap(s, maxchars) |
|
2 |
|
%LINEWRAP Separate a single string into multiple strings |
|
3 |
|
% C = LINEWRAP(S, MAXCHARS) separates a single string into multiple |
|
4 |
|
% strings by separating the input string, S, on word breaks. S must be a |
|
5 |
|
% single-row char array. MAXCHARS is a nonnegative integer scalar |
|
6 |
|
% specifying the maximum length of the broken string. C is a cell array |
|
7 |
|
% of strings. |
|
8 |
|
% |
|
9 |
|
% C = LINEWRAP(S) is the same as C = LINEWRAP(S, 80). |
|
10 |
|
% |
|
11 |
|
% Note: Words longer than MAXCHARS are not broken into separate lines. |
|
12 |
|
% This means that C may contain strings longer than MAXCHARS. |
|
13 |
|
% |
|
14 |
|
% This implementation was inspired a blog posting about a Java line |
|
15 |
|
% wrapping function: |
|
16 |
|
% http://joust.kano.net/weblog/archives/000060.html |
|
17 |
|
% In particular, the regular expression used here is the one mentioned in |
|
18 |
|
% Jeremy Stein's comment. |
|
19 |
|
% |
|
20 |
|
% Example |
|
21 |
|
% s = 'Image courtesy of Joe and Frank Hardy, MIT, 1993.' |
|
22 |
|
% c = linewrap(s, 40) |
|
23 |
|
% |
|
24 |
|
% See also TEXTWRAP. |
|
25 |
|
|
|
26 |
|
% Steven L. Eddins |
|
27 |
|
% $Revision: 1.7 $ $Date: 2006/02/08 16:54:51 $ |
|
28 |
|
|
|
29 |
|
error(nargchk(1, 2, nargin)); |
|
30 |
|
|
|
31 |
|
bad_s = ~ischar(s) || (ndims(s) > 2) || (size(s, 1) ~= 1); |
|
32 |
|
if bad_s |
|
33 |
|
error('S must be a single-row char array.'); |
|
34 |
|
end |
|
35 |
|
|
|
36 |
|
if nargin < 2 |
|
37 |
|
% Default value for second input argument. |
|
38 |
|
maxchars = 80; |
|
39 |
|
end |
|
40 |
|
|
|
41 |
|
% Trim leading and trailing whitespace. |
|
42 |
|
s = strtrim(s); |
|
43 |
|
|
|
44 |
|
% Form the desired regular expression from maxchars. |
|
45 |
|
exp = sprintf('(\\S\\S{%d,}|.{1,%d})(?:\\s+|$)', maxchars, maxchars); |
|
46 |
|
|
|
47 |
|
% Interpretation of regular expression (for maxchars = 80): |
|
48 |
|
% '(\\S\\S{80,}|.{1,80})(?:\\s+|$)' |
|
49 |
|
% |
|
50 |
|
% Match either a non-whitespace character followed by 80 or more |
|
51 |
|
% non-whitespace characters, OR any sequence of between 1 and 80 |
|
52 |
|
% characters; all followed by either one or more whitespace characters OR |
|
53 |
|
% end-of-line. |
|
54 |
|
|
|
55 |
|
tokens = regexp(s, exp, 'tokens').'; |
|
56 |
|
|
|
57 |
|
% Each element if the cell array tokens is single-element cell array |
|
58 |
|
% containing a string. Convert this to a cell array of strings. |
|
59 |
|
get_contents = @(f) f{1}; |
|
60 |
|
c = cellfun(get_contents, tokens, 'UniformOutput', false); |
|
61 |
|
|
|
62 |
|
% Remove trailing whitespace characters from strings in c. This can happen |
|
63 |
|
% if multiple whitespace characters separated the last word on a line from |
|
64 |
|
% the first word on the following line. |
|
65 |
|
c = deblank(c); |
|
66 |
|
|
|
67 |
|
|