-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathcbarticks.m
45 lines (40 loc) · 1.22 KB
/
cbarticks.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
function cbarticks(cb,cax,tint,pos)
% CBARTICKS(cb,cax,tint,pos)
%
% Transforms axis tick marks and labels to other values, e.g. for a
% colorbar that indexes an IMAGE type figure, so that the ticks, which
% would otherwise be marking color indices, agree with the actual values
% of what's being plotted in the figure and for which the axis is a
% colorbar.
%
% INPUT:
%
% cb Handle to an axis, especially, a colorbar from ADDCB
% cax Minimum and maximum of the color range
% tint If a single number: tick INTERVAL, cax(1):tint:cax(2)
% If two or more numbers: actual ticks themselves
% pos 'hor' or 'vert' position of the axis handle cb
%
% SEE ALSO:
%
% ADDCB, IMAGEF, IMAGEFDIR, IMAGEFNAN
%
% Last modified by charig-at-princeton.edu, 02/05/2016
% Last modified by fjsimons-at-alum.mit.edu, 07/26/2017
defval('tint',20)
defval('pos','hor')
if length(tint)==1
% Make sure the last one makes it regardless of tint
tix=unique([cax(1):tint:cax(2) cax(2)]);
else
tix=tint;
end
if strcmp(pos,'hor')
set(cb,'Xtick',scale(tix,get(cb,'xlim')))
set(cb,'XtickLabel',tix)
elseif strcmp(pos,'vert')
set(cb,'Ytick',scale(tix,get(cb,'ylim')))
set(cb,'YtickLabel',tix)
else
error('Specify valid orientation')
end