File data_analysis/gaussianity/gaussianity_plots.m changed (mode: 100644) (index 508863e..73ffa2b) |
... |
... |
function gaussianity_plots(trace, varargin) |
6 |
6 |
modeno = quadno/4; |
modeno = quadno/4; |
7 |
7 |
assert((modeno==round(modeno))&&(modeno>0)); |
assert((modeno==round(modeno))&&(modeno>0)); |
8 |
8 |
|
|
|
9 |
|
figwidth = 560; |
|
10 |
|
figheight = 420; |
|
11 |
|
|
9 |
12 |
modes = 1:modeno; |
modes = 1:modeno; |
10 |
13 |
subplotwidth = min(2,modeno); |
subplotwidth = min(2,modeno); |
11 |
14 |
subplotheight = ceil(modeno/subplotwidth); |
subplotheight = ceil(modeno/subplotwidth); |
12 |
15 |
|
|
13 |
16 |
normalize = true; |
normalize = true; |
14 |
17 |
export = false; |
export = false; |
|
18 |
|
mute = false; |
15 |
19 |
visible = 'on'; |
visible = 'on'; |
16 |
20 |
titlestr = 'pulse quadratures'; % generic name for data |
titlestr = 'pulse quadratures'; % generic name for data |
17 |
21 |
for k=1:2:length(varargin) |
for k=1:2:length(varargin) |
|
... |
... |
function gaussianity_plots(trace, varargin) |
20 |
24 |
normalize = varargin{k+1}; |
normalize = varargin{k+1}; |
21 |
25 |
case {'title','Title','titlestr'} |
case {'title','Title','titlestr'} |
22 |
26 |
titlestr = varargin{k+1}; |
titlestr = varargin{k+1}; |
|
27 |
|
case {'mute','Mute'} |
|
28 |
|
mute = varargin{k+1}; |
23 |
29 |
case {'modeorder','modes','Modes'} |
case {'modeorder','modes','Modes'} |
24 |
30 |
modeorder = varargin{k+1}'; |
modeorder = varargin{k+1}'; |
25 |
31 |
modes = modeorder(:)'; |
modes = modeorder(:)'; |
26 |
|
subplotwidth = size(modeorder,2); |
|
27 |
|
subplotheight = size(modeorder,1); |
|
|
32 |
|
subplotwidth = size(modeorder,1); |
|
33 |
|
subplotheight = size(modeorder,2); |
28 |
34 |
case {'export','Export','save','Save'} |
case {'export','Export','save','Save'} |
29 |
35 |
if ~(varargin{k+1}==false) |
if ~(varargin{k+1}==false) |
30 |
36 |
export = true; |
export = true; |
|
... |
... |
function gaussianity_plots(trace, varargin) |
35 |
41 |
error(['Unrecognized varargin-argument: ', varargin{k}]) |
error(['Unrecognized varargin-argument: ', varargin{k}]) |
36 |
42 |
end |
end |
37 |
43 |
end |
end |
|
44 |
|
if subplotheight > 3 |
|
45 |
|
figheight = (subplotheight/3)*figheight; |
|
46 |
|
end |
|
47 |
|
if subplotwidth > 3 |
|
48 |
|
figwidth = (subplotwidth/3)*figwidth; |
|
49 |
|
end |
38 |
50 |
|
|
39 |
51 |
stddevs = std(trace); |
stddevs = std(trace); |
40 |
52 |
inset = ' '; |
inset = ' '; |
|
... |
... |
function gaussianity_plots(trace, varargin) |
57 |
69 |
else |
else |
58 |
70 |
normalizestr = ''; |
normalizestr = ''; |
59 |
71 |
end |
end |
60 |
|
histfig = figure('visible',visible); |
|
61 |
|
cdffig = figure('visible',visible); |
|
62 |
|
qqfig = figure('visible',visible); |
|
63 |
|
kdensfig = figure('visible',visible); |
|
|
72 |
|
histfig = figure('visible',visible,'position', [0, 0, figwidth, figheight]); |
|
73 |
|
cdffig = figure('visible',visible,'position', [0, 0, figwidth, figheight]); |
|
74 |
|
qqfig = figure('visible',visible,'position', [0, 0, figwidth, figheight]); |
|
75 |
|
kdensfig = figure('visible',visible,'position', [0, 0, figwidth, figheight]); |
64 |
76 |
|
|
65 |
|
postprocess = @(m){ title('');... |
|
66 |
|
ntitle([inset, 'Mode no. ',num2str(m),10,... |
|
67 |
|
inset, 'std. deviations: ',10,... |
|
68 |
|
getstddevstr(m)],... |
|
69 |
|
'location','northwest');... |
|
70 |
|
legend({'q','p','x','y'}, 'Location', 'SouthEast')}; |
|
|
77 |
|
if mute |
|
78 |
|
postprocess = @(m){ title('');... |
|
79 |
|
ntitle([inset, 'Mode ',num2str(m)],... |
|
80 |
|
'location','northwest');... |
|
81 |
|
xlabel('');... |
|
82 |
|
ylabel('');}; |
|
83 |
|
else |
|
84 |
|
postprocess = @(m){ title('');... |
|
85 |
|
ntitle([inset, 'Mode ',num2str(m),10,... |
|
86 |
|
inset, 'std. deviations: ',10,... |
|
87 |
|
getstddevstr(m)],... |
|
88 |
|
'location','northwest');... |
|
89 |
|
legend({'q','p','x','y'}, 'Location', 'SouthEast')}; |
|
90 |
|
end |
71 |
91 |
s = 0; |
s = 0; |
72 |
92 |
for m=modes |
for m=modes |
73 |
93 |
s = s + 1; |
s = s + 1; |
74 |
94 |
change_current_figure(histfig); subplot(subplotheight, subplotwidth, s); hold all |
change_current_figure(histfig); subplot(subplotheight, subplotwidth, s); hold all |
75 |
95 |
hist(getsubtrace(m),50); |
hist(getsubtrace(m),50); |
76 |
96 |
postprocess(m); |
postprocess(m); |
|
97 |
|
xlim([-5,5]); |
|
98 |
|
if mute && s==numel(modes) |
|
99 |
|
legend({'q','p','x','y'}, 'Location', 'SouthEastOutside'); |
|
100 |
|
end |
77 |
101 |
|
|
78 |
102 |
change_current_figure(cdffig); subplot(subplotheight, subplotwidth, s); hold all |
change_current_figure(cdffig); subplot(subplotheight, subplotwidth, s); hold all |
79 |
103 |
arrayfun(@(n)cdfplot(trace(:,n)), getinds(m)); |
arrayfun(@(n)cdfplot(trace(:,n)), getinds(m)); |
80 |
104 |
postprocess(m); |
postprocess(m); |
|
105 |
|
xlim([-5,5]); |
|
106 |
|
if mute && s==numel(modes) |
|
107 |
|
legend({'q','p','x','y'}, 'Location', 'SouthEastOutside'); |
|
108 |
|
end |
81 |
109 |
|
|
82 |
110 |
change_current_figure(kdensfig); subplot(subplotheight, subplotwidth, s); hold all |
change_current_figure(kdensfig); subplot(subplotheight, subplotwidth, s); hold all |
83 |
111 |
arrayfun(@(n)ksdensity(trace(:,n)), getinds(m)); |
arrayfun(@(n)ksdensity(trace(:,n)), getinds(m)); |
84 |
112 |
postprocess(m); |
postprocess(m); |
|
113 |
|
xlim([-5,5]); |
|
114 |
|
if mute && s==numel(modes) |
|
115 |
|
legend({'q','p','x','y'}, 'Location', 'SouthEastOutside'); |
|
116 |
|
end |
85 |
117 |
|
|
86 |
118 |
change_current_figure(qqfig); subplot(subplotheight, subplotwidth, s); hold all |
change_current_figure(qqfig); subplot(subplotheight, subplotwidth, s); hold all |
87 |
119 |
qqplot(getsubtrace(m)); |
qqplot(getsubtrace(m)); |
88 |
120 |
postprocess(m); |
postprocess(m); |
|
121 |
|
if mute && s==numel(modes) |
|
122 |
|
legend({'q','p','x','y'}, 'Location', 'SouthEastOutside'); |
|
123 |
|
end |
89 |
124 |
end |
end |
90 |
125 |
|
|
91 |
126 |
suptitlestr = [' of ',titlestr, normalizestr]; |
suptitlestr = [' of ',titlestr, normalizestr]; |
|
... |
... |
function gaussianity_plots(trace, varargin) |
100 |
135 |
if export |
if export |
101 |
136 |
% note: hist does not work with pdf export. |
% note: hist does not work with pdf export. |
102 |
137 |
export_fig(histfig, [exportstr, '_', 'hist'],... |
export_fig(histfig, [exportstr, '_', 'hist'],... |
103 |
|
'-png', '-nocrop','-transparent') |
|
|
138 |
|
'-png', '-transparent') %'-nocrop' |
104 |
139 |
export_fig(cdffig, [exportstr, '_', 'cdf'],... |
export_fig(cdffig, [exportstr, '_', 'cdf'],... |
105 |
|
'-pdf', '-nocrop','-transparent') |
|
|
140 |
|
'-pdf','-transparent') |
106 |
141 |
export_fig(kdensfig, [exportstr, '_', 'kde'],... |
export_fig(kdensfig, [exportstr, '_', 'kde'],... |
107 |
|
'-pdf', '-nocrop','-transparent') |
|
|
142 |
|
'-pdf','-transparent') |
108 |
143 |
export_fig(qqfig, [exportstr, '_', 'qq'],... |
export_fig(qqfig, [exportstr, '_', 'qq'],... |
109 |
|
'-pdf', '-nocrop','-transparent') |
|
|
144 |
|
'-pdf','-transparent') |
110 |
145 |
end |
end |
111 |
146 |
end |
end |
112 |
147 |
|
|