function manualcb(zmin,zmax,cmap,varargin) %MANUALCB - custom colorbar % % Usage: % manualcb(min,max,colormap,options) % % Available options: % - 'fontsize' : default is 12 % - 'smallbars' : bars next to each tick (default is false) % - 'position' : colorbar position in normalized units % - 'orientation' : 'vertical' (default) or 'horizontal' % - 'title' : colorbar title % - 'tick' : specified values of tick labels % - 'ticksep' : spacing between ticks % - 'inverttickposition' : put ticks on the left hand side for vertical cb %check inputs if nargin<3, help manualcb error('bad usage'); end if zmin>zmax, error('zmin should be smaller than zmax'); end %Get plot axes mainaxes = gca; %process options options = pairoptions(varargin{:}); if exist(options,'tick') & exist(options,'ticksep'), error('only one of tick or ticksep can be specified'); end fontsize = getfieldvalue(options,'fontsize',12); smallbars = getfieldvalue(options,'smallbars',false); %Colorbar position if ~exist(options,'position'), position = plotboxpos; xstart = position(1)+position(3)+0.01; ystart = position(2); width = .02; height = position(4); else position = getfieldvalue(options,'position'); xstart = position(1); ystart = position(2); width = position(3); height = position(4); end axes('Units','normalized','Position',[xstart ystart width height],'XTickLabel','','YTickLabel','','Visible','on'); xlim([0 1]); ylim([0 1]); %Prepare ticks if ~exist(options,'log'), deltaz = getfieldvalue(options,'ticksep',dtick(zmax-zmin)); ztick = getfieldvalue(options,'tick',(deltaz*ceil(zmin/deltaz)):deltaz:zmax); if (any(ztick>zmax) | any(ztick