combined colormap with contour labels
Additionally contour labels can be added to the contour plot. This example enhances the code previous code example.
% use these libraries addpath('ColorbarUtilities'); addpath('freezeColors'); hold on; caxis([0 1]); colormap(jet(colorDepth)); hplot = pcolor(x,y,data); shading flat % colorbar hcb = colorbar('location','EastOutside', ... 'FontSize' , FontSize , ... 'FontName' , FontName , ... 'Ylim' , [0 1] , ... 'Box' , 'on' , ... 'TickDir' , 'in' , ... 'TickLength' , [.02 .02] , ... 'LineWidth' , 0.6); % freeze colorbar cbfreeze; % apply label to colorbar % - here with cblabel hcLabel = cblabel(zLabelText); set([hcLabel], ... 'FontSize' , FontSize , ... 'FontName' , FontName); % freeze colors (allows multiple colormaps) freezeColors; % plot contour with different colormap colormap(gray(colorDepth)); [C,hfigc] = contour(x, y, data,[0:0.1:1]); set(hfigc, 'LineWidth',1.0); % add text to lines set(hfigc, ... 'ShowText','on', ... 'TextStep',get(hfigc,'LevelStep')*2 ); % modify color labels hcollab = clabel(C,hfigc,'LabelSpacing',350); % set(hcollab, ... 'BackgroundColor',[.99 .99 .99], ... 'Edgecolor',[.1 .1 .1], ... 'FontSize',FontSize * 0.5, ... 'FontName', FontName, ... 'Color',[0 0 0], ... 'Rotation',0, ... 'HorizontalAlignment','center', ... 'Margin',2) hold off; |
Unfortunately the position of the labels can not be modified with useful properties.