-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot2D.m
55 lines (45 loc) · 991 Bytes
/
plot2D.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
function argout = plot2D(varargin)
%PLOT2D Plots data as 2D contour plot.
%
% PLOT2D(x, y, o)
% PLOT2D(ax, ...)
%
% INPUT:
% ax - Axis handle for plot. If not given, the data is plotted in
% the current axis, as returned by gca.
% x, y - x- and y-axis data.
% o - Ordinate data.
%
% OUTPUT:
% phandle - plot handle
%
import esr_analyses.*
import esr_analyses.utils.*
%% Input Analyses
if ishghandle(varargin{1}, 'axes')
ax = varargin{1};
x = varargin{2};
y = varargin{3};
o = varargin{4};
else
ax = gca;
x = varargin{1};
y = varargin{2};
o = varargin{3};
end
%% Data preparation
if ~all(size(o) == [length(y) length(x)])
o = reshape(o, [length(x) length(y)])';
end
if ~all(size(o) == [length(y) length(x)])
error('Dimensions of axes and ordinate data do not match.')
end
%% Plot
h = imagesc(ax, x, y, o);
ax.YDir = 'normal';
colorbar;
%% Argout
if nargout > 0
argout = h;
end
end