Changeset 1103 for trunk/src/plot_field.m
- Timestamp:
- May 8, 2021, 11:01:15 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plot_field.m
r1098 r1103 865 865 866 866 %set for grey scale setting 867 ColorMap='default'; 867 868 if isfield(PlotParam.Scalar,'CheckBW') && ~isempty(PlotParam.Scalar.CheckBW) 868 BW=PlotParam.Scalar.CheckBW; %BW=0 color imposed, else gray scale imposed. 869 else % BW imposed automatically chosen 870 BW=(siz==2) && (isa(A,'uint8')|| isa(A,'uint16'));% non color images represented in gray scale by default 871 PlotParamOut.Scalar.CheckBW=BW; 872 end 873 869 ColorMap=PlotParam.Scalar.CheckBW; %BW=0 color imposed, else gray scale imposed. 870 elseif ((siz==2) && (isa(A,'uint8')|| isa(A,'uint16')))% non color images represented in gray scale by default 871 ColorMap='grayscale'; 872 end 873 PlotParamOut.Scalar.CheckBW=ColorMap; 874 874 % determine the plot option 'image' or 'contours' 875 875 CheckContour=0; %default … … 915 915 PlotParamOut.Scalar.Npx=size(A,2); 916 916 PlotParamOut.Scalar.Npy=size(A,1); 917 % if siz==2917 918 918 % case of contour plot 919 919 if CheckContour … … 946 946 y_cont=Coord_y(1):-sizpy:Coord_y(end); % pixel x coordinates for image display 947 947 948 %axes(haxes)% set the input axes handle as current axis949 950 % colormap(map);951 948 tag_axes=get(haxes,'Tag');% axes tag 952 949 Opacity=1; … … 972 969 %determine the color scale and map 973 970 caxis([abscontmin abscontmax]) 974 if BW971 if strcmp(ColorMap,'grayscale') 975 972 vec=linspace(0,1,(abscontmax-abscontmin)/interval);%define a greyscale colormap with steps interval 976 973 map=[vec' vec' vec']; 977 974 colormap(map); 978 else 979 colormap('jet'); % default matlab colormap ('jet') 975 elseif strcmp(ColorMap,'BuYlRd') 976 hh=load('BuYlRd.mat'); 977 colormap(hh.BuYlRd); 978 else 979 colormap(ColorMap); 980 980 end 981 981 else %usual images (no contour) 982 982 % set colormap for image display 983 if BW983 if strcmp(ColorMap,'grayscale') 984 984 vec=linspace(0,1,255);%define a linear greyscale colormap 985 985 map=[vec' vec' vec']; … … 988 988 A=uint16(sum(A,3));%sum the three color components for color images displayed with BW option 989 989 end 990 elseif strcmp(ColorMap,'BuYlRd') 991 hh=load('BuYlRd.mat'); 992 colormap(hh.BuYlRd); 990 993 else 991 994 if siz==3 && CheckFixScalar % true color images rescaled by MaxA 992 995 A=uint8(255*double(A)/double(MaxA)); 993 996 end 994 colormap( 'default'); % standard false colors for div, vort , scalar fields997 colormap(ColorMap); % standard false colors for div, vort , scalar fields 995 998 end 996 999 … … 1123 1126 if test_vec 1124 1127 %vector scale representation 1125 if size(vec_U,1)==numel(vec_Y) && size(vec_U,2)==numel(vec_X) ;% x, y coordinate variables1128 if size(vec_U,1)==numel(vec_Y) && size(vec_U,2)==numel(vec_X) % x, y coordinate variables 1126 1129 [vec_X,vec_Y]=meshgrid(vec_X,vec_Y); 1127 1130 end … … 1201 1204 1202 1205 % take flags into account: add flag colors to the list of colors 1203 sizlist=size(colorlist); 1204 nbcolor=sizlist(1); 1206 nbcolor=size(colorlist,1); 1205 1207 if test_black 1206 1208 nbcolor=nbcolor+1; … … 1223 1225 %plot vectors: 1224 1226 quiresetn(haxes,vec_X,vec_Y,vec_U,vec_V,scale,colorlist,col_vec); 1225 1226 1227 else 1227 1228 hvec=findobj(haxes,'Tag','vel'); … … 1231 1232 PlotParamOut=rmfield(PlotParamOut,'Vectors'); 1232 1233 end 1233 % nbvar=0;1234 1234 1235 1235 %store the coordinate extrema occupied by the field … … 1297 1297 alpha=0.3 ;%length arrow 1298 1298 rot=alpha*[cos(theta) -sin(theta); sin(theta) cos(theta)]'; 1299 1299 1300 %find the existing lines 1300 1301 h=findobj(haxes,'Tag','vel');% search existing lines in the current axes 1301 1302 sizh=size(h); 1302 %set(h,'EraseMode','xor');1303 1303 set(haxes,'NextPlot','replacechildren'); 1304 1304 1305 %drawnow1306 1305 %create lines (if no lines) or modify them 1307 1306 if ~isequal(size(col_vec),size(x)) 1308 1307 col_vec=ones(size(x));% case of error in col_vec input 1309 1308 end 1310 sizlist=size(colorlist); 1311 ncolor=sizlist(1); 1312 1313 for icolor=1:ncolor 1309 nbcolor=size(colorlist,1); 1310 1311 for icolor=1:nbcolor 1314 1312 %determine the line positions for each color icolor 1315 1313 ind=find(col_vec==icolor); … … 1363 1361 end 1364 1362 end 1365 if sizh(1) > 2*n color1366 for icolor=n color+1 : sizh(1)/2%delete additional objects1363 if sizh(1) > 2*nbcolor 1364 for icolor=nbcolor+1 : sizh(1)/2 %delete additional objects 1367 1365 delete(h(2*icolor-1)) 1368 1366 delete(h(2*icolor))
Note: See TracChangeset
for help on using the changeset viewer.