function toplot(top_lat, top_lon, topog, min_depth, max_depth, tic)
% 
% ------------
% purpose: to plot topography
%
% usage: to run in matlab
%   toplot(top_lat, top_lon, topog, min_depth, max_depth, tic)
%
%   input: top_lat, top_lon, topog are output from get_topog.m
%          min_depth, max_depth : minimum and maximum depths for 
%                                 clipping data
%          tic: step (in meter) for labelling the colorbar
%   
%   e.g    toplot(top_lat, top_lon, topog, 0 , 6000, 500)
%        
% ------------
%
h1 = axes('Position',[.1 .12 .70 .70], 'Box','on');
surface(top_lon,top_lat,topog)
h = jet(100);
colormap(h)
shading flat
ncol = [min_depth max_depth];
caxis(ncol)
axis([ min(top_lon) max(top_lon) min(top_lat) max(top_lat) ]);
set(gca, 'TickDir', 'out');
xlabel('Longitude')
ylabel('Latitude')
title('TOPOGRAPHY (m)', 'FontWeight', 'bold', 'FontSize', 12)
h2 = axes('Position',[.82 .12 .03 .70],'Box','on');
axes(h2)
nh = size(h,1);
image([0 1], ncol, [1:nh]')
set(h2,'yticklabels','');
set(h2,'xticklabels','')
range = min_depth:tic:max_depth;
for i = 1:length(range)
    if (range(i) > 0), range(i) = - range(i); end;
    s = sprintf('%5g',range(i));
    posy = min_depth + (i-1)*tic;
    text(1.5, posy, s, 'horizontalalignment', 'left','FontSize',10);
end
print -dpsc topo
