function ColorLimit=new_climit(BeginSlot,EndSlot,CDmin,CDmax,CmLength);

PBeginSlot=(BeginSlot-1)/(CmLength-1);
PEndSlot=(EndSlot-1)/(CmLength-1);
PCmRange=PEndSlot-PBeginSlot;

DataRange=CDmax-CDmin;
ClimRange=DataRange/PCmRange;
NewCmin=CDmin-(PBeginSlot*ClimRange);
NewCmax=CDmax+(1-PEndSlot)*ClimRange;
ColorLimit=[NewCmin,NewCmax];
% if NewCmin<0
%     NewCmin=-1000;
% end
% ColorLimit=[NewCmin,NewCmax];
end