-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformatplot.m
More file actions
36 lines (30 loc) · 941 Bytes
/
formatplot.m
File metadata and controls
36 lines (30 loc) · 941 Bytes
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
function h = formatplot(h,D,varargin)
% Handle options
nG = size(D,2);
C = parsevarargin(varargin,'cluster',1:nG);
bw = parsevarargin(varargin,'bwidth',1);
yc = parsevarargin(varargin,'ycut',0);
zl = parsevarargin(varargin,'zeroline','-');
if numel(bw)>1; bw = bw(1); end
% X limit
XLIM = nan(1,2);
XLIM(2) = (nG+1.2+sum(diff(C(1:nG))))*bw;
XLIM(1) = 0.8*bw;
h.XLim = XLIM;
% Y limit
[~,YLIM] = lims([],D(:),[.1 .1]);
if ~yc && all(~(D(~isnan(D(:)))>0)); YLIM(2)=0; end
if ~yc && all(~(D(~isnan(D(:)))<0)); YLIM(1)=0; end
h.YLim = YLIM;
% Zero line
if ~isempty(zl) && ~ischar(zl); zl='-'; end
if YLIM(1)<0 && YLIM(2)>0 && ~isempty(zl)
hl = line(h.XLim,[0 0],'color',[.4 .4 .4],'parent',h,'linewidth',.5,'linestyle',zl);
hold on
uistack(hl,'bottom');
end
% Axis format
% h.Box = 'on';
h.XTickLabel = '';
h.XTick = ((1:nG) + reshape(C,1,[]))*bw - bw/2;
end