Revision 495
(checked in by cbc, 12 years ago)
|
Initial import of Stark code.
|
Line | |
---|
1 |
|
---|
2 |
function colorbin(hc,cval); |
---|
3 |
|
---|
4 |
% |
---|
5 |
% COLORBIN creates a "binned" colormap/colorbar for the current |
---|
6 |
% figure instead of the smooth colorbar. |
---|
7 |
% |
---|
8 |
% COLORBIN requires the following arguments: |
---|
9 |
% hc (opt) handle to the current colorbar |
---|
10 |
% cval vector of bin limits |
---|
11 |
% |
---|
12 |
% colorbin(hc,cval); |
---|
13 |
% |
---|
14 |
% Calls: none |
---|
15 |
% |
---|
16 |
% Catherine R. Edwards |
---|
17 |
% Last modified: 31 Jul 2001 |
---|
18 |
% |
---|
19 |
|
---|
20 |
if nargin==1 |
---|
21 |
cval=hc; |
---|
22 |
end |
---|
23 |
|
---|
24 |
cval=cval(:)'; |
---|
25 |
hc=colorbar; clim=get(gca,'clim'); dc=clim(2)-clim(1); |
---|
26 |
map=colormap; nn=length(map); |
---|
27 |
|
---|
28 |
% find where in colormap cvals lie |
---|
29 |
cind=max(round((cval-cval(1))*nn/dc),1); |
---|
30 |
len=diff([cind(cind<=nn) nn]); |
---|
31 |
vals=map(cind(cind<=nn)+len,:); |
---|
32 |
rs=rldecode(len,vals(:,1)); |
---|
33 |
gs=rldecode(len,vals(:,2)); |
---|
34 |
bs=rldecode(len,vals(:,3)); |
---|
35 |
|
---|
36 |
colormap([rs gs bs]); |
---|
37 |
hc=colorbar; |
---|