forked from sgarrettroe/data_analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy2dPlot.m
142 lines (126 loc) · 4.17 KB
/
my2dPlot.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
function varargout=my2dPlot(x,y,z,varargin)
%my2dPlot should plot contour plots and projections of 2d data
%returning handles to the individual axes that make the plot
%function varargout=my2dPlot(x,y,z,['opt',val])
%
%RB, 03052011: introduced variable zlimit, which changes the range over
%which the contours are drawn. zlimit <= 0 is default and uses the data,
%zlimit > 0 and <= 1 will plot a ratio, zlimit > 0 limits the contours to
%the range specified.
%
%fix contour levels and colors
n_contours = 12;
flag_pumpprobe = true;
zlimit = 0;
mask = ones(size(z));
mask_level = [];
mask_from = [];
flag_projections = true;
while length(varargin)>=2
arg = varargin{1};
val = varargin{2};
switch lower(arg)
case 'zlimit'
zlimit = val;
case 'n_contours'
n_contours = val;
if mod(n_contours,2)
warning('my2dPlot4: Odd number of contour lines may produce unexpected results!')
end
case {'pumpprobe_style','pumpprobe'}
flag_pumpprobe = val;
case 'mask'
mask = val;
case 'mask_level'
mask_level = val;
case 'mask_from'
mask_from = val;
if size(mask_from)~=size(z),error('mask_from size must match input size');end
case 'projections'
if strcmpi(val,'on')
flag_projections = true;
elseif strcmpi(val,'off')
flag_projections = false;
elseif islogical(val)
flag_projections=val;
end
otherwise
error(['my2dPlot: unknown option ',arg])
end
varargin = varargin(3:end);
end
if ~isempty(mask_level) & ~isempty(mask_from)
mask = ones(size(mask_from));
mask(abs(mask_from) < abs(mask_level*min(mask_from(:)))) = nan;
end
z = z.*mask;
pos = get(gcf,'Position');
if get(gcf,'WindowStyle')~='docked',
set(gcf,'Position',[pos(1) pos(2) 415 416],'Color',[0.9 0.9 0.9]);
end
%contour properties
cont_left = 0.18;
cont_bot = 0.15;
cont_w = 0.6;
cont_h = 0.6;
%projecttion properties
proj_h= 0.2;
map=myMapRGB2(n_contours);
%MAX = max([max(z(:)) abs(min(z(:)))]);
%MAX = max(abs(z(:)));
%level_list = linspace(-MAX,MAX,n_contours+2);
% zlimit determines what is what the range is that is covered by the
% contours. If limit <= 0, the data is used to determine it (old behaviour
% and default). If zlimit is between 0 and 1, it will use the data as well,
% but only plots a fraction of it (the number between 0 and 1. If zlimit is
% large than 1, it will use that value.
if zlimit <= 0
[ca, level_list]= myCaxis2(z, n_contours);
%ca
elseif zlimit > 0 && zlimit <= 1
[ca, level_list] = myCaxis2(z, n_contours);
ca = ca * zlimit;
level_list = level_list * zlimit;
else
ca = [-zlimit zlimit];
level_list = linspace(-zlimit, zlimit, n_contours+2);
end
contourf(x,y,z,level_list);
colormap(map)
caxis(ca);
if flag_pumpprobe
x_label = '\omega_{probe} / 2\pic';
y_label = '\omega_{pump} / 2\pic';
else
x_label = '\omega_1 / 2\pic';
y_label = '\omega_3 / 2\pic';
end
xlabel(x_label);
ylabel(y_label);
%axis square%this makes things not line up well...
a(1)=gca;
set(a(1),'Position',[cont_left cont_bot cont_w cont_h]);
line([x(1) x(end)],[x(1) x(end)],'Color',[0 0 0]);
xlim = get(a(1),'XLim');
ylim = get(a(1),'YLim');
if flag_projections
a(2)=axes('Position',[cont_left, cont_bot+cont_h, cont_w, proj_h]);
%line(x,sum(z,2)','Color',[0 0 0]);
line(x,sum(z,1),'Color',[0 0 0]);
set(a(2),'XTickLabel',[],'YTickLabel',[],'Xlim',xlim);
a(3)=axes('Position',[cont_left+cont_w, cont_bot, proj_h, cont_h]);
line(sum(z,2)',y,'Color',[0 0 0]);
set(a(3),'XTickLabel',[],'YTickLabel',[],'YLim',ylim);
axes(a(2))
%linkaxes([a(2) a(1)],'x')
%linkaxes([a(3) a(1)],'y')
hlink_x = linkprop([a(1),a(2)],'XLim');
hlink_y = linkprop([a(1),a(3)],'YLim');
key_x = 'graphics_linkprop';
key_y = 'graphics_linkprop';
setappdata(a(2),key_x,hlink_x);
setappdata(a(3),key_y,hlink_y);
end
for i = 1:nargout
varargout{i} = a(i);
end