0001 function PlotColorMap(data,dimm,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 cutoffs = [];
0055 hgamma = 1;
0056 gamma = 1;
0057 hg = 0;
0058 colorspace = 'rgb';
0059 threshold = 0.01;
0060 drawBar = 0;
0061 type = 'linear';
0062 [y,x] = size(data);
0063 x = 1:x;y = 1:y;
0064 ydir = 'normal';
0065
0066
0067 if nargin < 1,
0068 error('Incorrect number of parameters (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0069 end
0070 if nargin == 1,
0071 dimm = 1;
0072 end
0073 if isa(dimm,'char'),
0074 varargin = {dimm varargin{:}};
0075 dimm = 1;
0076 end
0077
0078
0079 for i = 1:2:length(varargin),
0080 if ~ischar(varargin{i}),
0081 error(['Parameter ' num2str(i+2) ' is not a property (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).']);
0082 end
0083 switch(lower(varargin{i})),
0084
0085 case 'threshold',
0086 threshold = varargin{i+1};
0087 if ~isdscalar(threshold,'>=0'),
0088 error('Incorrect value for property ''threshold'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0089 end
0090 case 'x',
0091 x = varargin{i+1};
0092 if ~isdvector(x),
0093 error('Incorrect value for property ''x'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0094 end
0095 case 'y',
0096 y = varargin{i+1};
0097 if ~isdvector(y),
0098 error('Incorrect value for property ''y'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0099 end
0100 case 'cutoffs',
0101 cutoffs = varargin{i+1};
0102 if ~isdvector(cutoffs,'#2','<') & ~isempty(cutoffs),
0103 error('Incorrect value for property ''cutoffs'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0104 end
0105 case 'hgamma',
0106 hg = 1;
0107 hgamma = varargin{i+1};
0108 if ~isdscalar(hgamma,'>=0'),
0109 error('Incorrect value for property ''hgamma'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0110 end
0111 case 'gamma',
0112 gamma = varargin{i+1};
0113 if ~isdscalar(gamma,'>=0'),
0114 error('Incorrect value for deprecated property ''gamma'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0115 end
0116 case 'colorspace',
0117 colorspace = lower(varargin{i+1});
0118 if ~isastring(colorspace,'hsv','rgb'),
0119 error('Incorrect value for property ''colorspace'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0120 end
0121 case 'bar',
0122 drawBar = lower(varargin{i+1});
0123 if ~isastring(drawBar,'on','off'),
0124 error('Incorrect value for property ''bar'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0125 end
0126 case 'type',
0127 type = lower(varargin{i+1});
0128 if ~isastring(type,'linear','circular'),
0129 error('Incorrect value for property ''type'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0130 end
0131 case 'ydir',
0132 ydir = lower(varargin{i+1});
0133 if ~isastring(ydir,'normal','reverse'),
0134 error('Incorrect value for property ''ydir'' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).');
0135 end
0136 otherwise,
0137 error(['Unknown property ''' num2str(varargin{i}) ''' (type ''help <a href="matlab:help PlotColorMap">PlotColorMap</a>'' for details).']);
0138
0139 end
0140 end
0141
0142
0143 x = x(:);
0144 y = y(:);
0145 if hg == 0,
0146 hgamma = 1/gamma;
0147 end
0148 if ~isempty(cutoffs),
0149 m = cutoffs(1);
0150 M = cutoffs(2);
0151 else
0152 m = min(min(data));
0153 M = max(max(data));
0154 end
0155 if m == M, M = m+1; end
0156 if isnan(m), m = 0; M = 1; end
0157 if length(dimm) == 1,
0158 dimm = dimm*ones(size(data));
0159 end
0160
0161 f = gcf;
0162 a = gca;
0163
0164
0165 data = squeeze(data);
0166 dimm = squeeze(dimm);
0167 p = imagesc(x,y,data,[m M]);
0168 set(a,'color',[0 0 0]);
0169 if any(dimm(:)~=1),
0170 alpha(p,1./(1+threshold./(dimm+eps)));
0171 end
0172
0173
0174 set(a,'ydir',ydir,'tickdir','out','box','off');
0175 if ~isempty(x) && length(x) ~= 1,
0176 PiecewiseLinearAxis(x);
0177 end
0178 if ~isempty(y) && length(y) ~= 1,
0179 PiecewiseLinearAxis(y,'y');
0180 end
0181
0182
0183 colormap(Bright(100,'hgamma',hgamma,'type',type));
0184 if strcmp(drawBar,'on'),
0185 b = colorbar('vert');
0186 set(b,'xtick',[],'tickdir','out','box','off','ycolor','k');
0187 set(f,'currentaxes',a);
0188 end
0189
0190