From: jenya polyakova on
Dear everybody, I have this code which I modified slightly from the code I borrowed in link exchange (plotclr.m). The problem with this code is that it does not plot points above or below miv and mav. I want these points to be plotted but as very red on my colorbar or very blue on my colorbar. Right now very red on my colorbar refers to the point specified by mav and very blue is corresponds to miv.
Any suggestions please on how to modify this code? THANKS

%this sets up the colorbar
map=colormap;
h=colorbar;
set(h,'ylim',[1 length(map)]);
yal=linspace(1,length(map),5);
set(h,'ytick',yal);
% Create the yticklabels
miv=0;
mav=312;
ytl=linspace(miv,mav,5);
s=char(5,4);
for i=1:5
B=sprintf('%-4.0f',ytl(i));
s(i,1:length(B))=B;
end
set(h,'yticklabel',s);

plotclr(x,y,v,miv,mav);

THE FUNCTION:
function h = plotclr(x,y,v,miv,mav)
map=colormap;
clrstep = (mav-miv)/size(map,1) ;
% Plot the points
hold on
for nc=1:size(map,1)
iv = find(v>miv+(nc-1)*clrstep & v<=miv+nc*clrstep) ;
plot(x(iv),y(iv),marker,'color',map(nc,:),'markerfacecolor',map(nc,:))
end
hold off
grid on
view(2)