CLEVELS Extract the contour levels from the contour matrix CALL: [CL, c1] = clevels(C) CL = [level1 level2, ... ] vector of contour levels (like the one you give into CONTOUR when you want manual control of the contour levels). C1 = [NaN x1 x2 x3 ... NaN x1 x2 x3 ...; NaN y1 y2 y3 ... NaN y1 y2 y3 ...] contour matrix with levels and pairs set to NaN's. C = [level1 x1 x2 x3 ... level2 x1 x2 x3 ...; pairs1 y1 y2 y3 ... pairs2 y1 y2 y3 ...] contour matrix as described in CONTOURC Example: c = contour(peaks); [cl, c1] = clevels(c); plot(c1(1,:),c1(2,:)); cltext(cl) See also contourc, ecolorbar
Display colorbar with discrete color axis for filled contour plot | |
Plot a spectral density |
001 function [CL,c]=clevels(c) 002 %CLEVELS Extract the contour levels from the contour matrix 003 % 004 % CALL: [CL, c1] = clevels(C) 005 % 006 % CL = [level1 level2, ... ] vector of contour levels (like the one you 007 % give into CONTOUR when you want manual 008 % control of the contour levels). 009 % C1 = [NaN x1 x2 x3 ... NaN x1 x2 x3 ...; 010 % NaN y1 y2 y3 ... NaN y1 y2 y3 ...] 011 % contour matrix with levels and pairs set to NaN's. 012 % C = [level1 x1 x2 x3 ... level2 x1 x2 x3 ...; 013 % pairs1 y1 y2 y3 ... pairs2 y1 y2 y3 ...] 014 % contour matrix as described in CONTOURC 015 % 016 % Example: 017 % 018 % c = contour(peaks); 019 % [cl, c1] = clevels(c); 020 % plot(c1(1,:),c1(2,:)); 021 % cltext(cl) 022 % 023 % See also contourc, ecolorbar 024 025 % History 026 % revised pab dec 2003 027 % minor changes 028 % revised pab 03.07.2001 029 % -changed name from levels to clevels 030 % - added sort and removal of duplicate levels by unique. 031 %Time-stamp:<Last updated on 00/06/30 at 14:32:43 by even@gfi.uib.no> 032 %File:<d:/home/matlab/levels.m> 033 034 % BEWARE: In the contour matrix from contourf there is a "fictious" 035 % contour level, max(max(data)), and it's given as a point. this is probably 036 % useful for functions using the contour matrix, as a color reference or 037 % something, but why is not the same done for min(min(data))? It has nothing 038 % to do with wich end of the scale occupies most of the area, it's always in 039 % the max-end. 040 % 041 % Anyway, CLEVELS does not extract this bogus "contourlevel". 042 043 044 error(nargchk(1,1,nargin)); 045 limit = size(c,2); 046 i=1;j=1; 047 while (i <= limit) 048 CL(j) = c(1,i); 049 pairs = c(2,i); 050 c(:,i) = NaN; 051 i = i+pairs+1; 052 % if j==1 | cont(j)~=cont(j-1) 053 j=j+1; 054 % end 055 end 056 057 % remove the bogus level in the end of c 058 %CL=CL(1:length(CL)-1); 059 % sort and remove duplicate levels 060 CL = unique(CL); 061 062 063
Comments or corrections to the WAFO group