function mark_delays(scan_file, range, markerstyle, markersize, color_map, bar_location) scan = load(scan_file); data_sizes = size(scan.delay_values); %color_map = load('blue_map.ddt'); %color_map = cool(128); %color_map = autumn(140); %color_map = color_map(1:128,:); map_size = size(color_map,1); for y_index = 1:size(scan.y_ticks,2) for x_index = 1:size(scan.x_ticks,2) value = scan.delay_values(y_index,x_index); fill_flag = 1; if value < range(1) color = color_map(1,:); fill_flag = 0; elseif value > range(2) color = color_map(map_size,:); else c_index = round(map_size*(value-range(1))/(range(2)-range(1))); if c_index <= 0 color = color_map(1,:); else color = color_map(c_index,:); end end x = scan.x_ticks(x_index); y = scan.y_ticks(y_index); if fill_flag == 1 plot(x, y, markerstyle, 'Color',color,'MarkerFaceColor',color,'MarkerSize',markersize); else plot(x, y, markerstyle, 'Color','k', 'MarkerSize',markersize); end end end % now draw a colorbar if required: if nargin > 5 x_range = get(gca,'XLim'); y_range = get(gca,'Ylim'); if strcmp(bar_location,'bottom') height = (y_range(2)-y_range(1))/20; width = (x_range(2)-x_range(1))/map_size; for c_index = 1:map_size color = color_map(c_index,:); rectangle('Position',[x_range(1)+(c_index-1)*width y_range(2)-height width height], 'FaceColor',color,'EdgeColor',color); end text(x_range(1)-markersize*3, y_range(2)+markersize*2, num2str(range(1)), 'FontSize',markersize); text(x_range(2)+markersize, y_range(2)+markersize*2, num2str(range(2)), 'FontSize',markersize); elseif strcmp(bar_location,'right') height = (y_range(2)-y_range(1))/map_size; width = (x_range(2)-x_range(1))/20; for c_index = 1:map_size color = color_map(c_index,:); rectangle('Position',[x_range(2)-width y_range(2)-c_index*height width height], 'FaceColor',color,'EdgeColor',color); end text(x_range(2)+markersize, y_range(1), num2str(range(2)), 'FontSize',markersize*2); text(x_range(2)+markersize, y_range(2), num2str(range(1)), 'FontSize',markersize*2); line([x_range(2)-width ; x_range(2)], [(y_range(1)+y_range(2))/2 ; (y_range(1)+y_range(2))/2],'Color','k'); text(x_range(2)+markersize, (y_range(1)+y_range(2))/2, num2str((range(1)+range(2))/2), 'FontSize',markersize*2); elseif strcmp(bar_location,'top') height = (y_range(2)-y_range(1))/20; width = (x_range(2)-x_range(1))/map_size; for c_index = 1:map_size color = color_map(c_index,:); rectangle('Position',[x_range(1)+(c_index-1)*width y_range(1) width height], 'FaceColor',color,'EdgeColor',color); end text(x_range(1)-markersize, y_range(1)-markersize*2, num2str(range(1)), 'FontSize',markersize); text(x_range(2)-markersize, y_range(1)-markersize*2, num2str(range(2)), 'FontSize',markersize); else disp(['sorry, ''' bar_location ''' option is not supported']); beep end end