Changeset 1200 for trunk/src/plot_field.m
- Timestamp:
- Mar 20, 2026, 4:42:36 PM (22 hours ago)
- File:
-
- 1 edited
-
trunk/src/plot_field.m (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plot_field.m
r1195 r1200 178 178 AxeData=get(haxes,'UserData'); 179 179 180 %% 2D plots 181 if isempty(index_2D) 182 plot_plane([],[],haxes,[]);%removes images or vector plots in the absence of 2D field plot 180 %% 2D plots 181 if isempty(index_2D) %removes images or vector plots in the absence of 2D field plot 182 hima=findobj(haxes,'Tag','ima');% search existing image in the current axes 183 if ishandle(hima) 184 delete(hima) 185 end 186 hvec=findobj(haxes,'Tag','vel');% search existing vectors in the current axes 187 if ~isempty(hvec) 188 delete(hvec); 189 end 183 190 else %plot 2D field 184 % if ~exist('PosColorbar','var'),PosColorbar=[];end;191 % if ~exist('PosColorbar','var'),PosColorbar=[];end; 185 192 [~,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo(index_2D),haxes,PlotParamOut); 186 193 AxeData.NbDim=2; 187 if testzoomaxes && isempty(errormsg) 188 [zoomaxes,PlotParamOut,~,errormsg]=plot_plane(Data,CellInfo(index_2D),zoomaxes,PlotParamOut); 194 if testzoomaxes && isempty(errormsg)% updater the plot on the attached axis 195 PlotParamZoom=PlotParamOut; 196 PlotParamZoom.Axes.CheckFixLimits=1; 197 XLim=get(zoomaxes,'XLim'); 198 YLim=get(zoomaxes,'YLim'); 199 PlotParamZoom.Axes.MinX=XLim(1); 200 PlotParamZoom.Axes.MaxX=XLim(2); 201 PlotParamZoom.Axes.MinY=YLim(1); 202 PlotParamZoom.Axes.MaxY=YLim(2); 203 PlotParamZoom.Axes.CheckZoomFig=0; 204 [zoomaxes,~,~,errormsg]=plot_plane(Data,CellInfo(index_2D),zoomaxes,PlotParamZoom); 189 205 AxeData.ZoomAxes=zoomaxes; 190 206 end … … 275 291 % --- plot 0D fields: display data values without plot 276 292 %------------------------------------------------------------------ 277 function errormsg=plot_text(FieldData,CellInfo, htext)293 function errormsg=plot_text(FieldData,CellInfo,~) 278 294 279 295 errormsg=''; 280 txt_cell={};281 Data={};282 296 VarIndex=[]; 283 for icell=1:length(CellInfo) 284 297 for icell=1:length(CellInfo) 285 298 % select types of variables to be projected 286 299 ListProj={'VarIndex_scalar','VarIndex_image','VarIndex_color','VarIndex_vector_x','VarIndex_vector_y'}; … … 617 630 end 618 631 Val=pdf2stat(x,pdf_val); 619 Column= mat2cell(Val,ones(13,1),ones(1,size(Val,2)));632 Column=num2cell(Val,ones(13,1),ones(1,size(Val,2))); 620 633 if size(Val,2)==1%single component 621 634 TitleBar={VarName}; … … 665 678 test_ima=0; %default: test for image or map plot 666 679 test_vec=0; %default: test for vector plots 667 test_black=0;668 680 test_false=0; 669 681 test_C=0; … … 681 693 ivar_Y=CellInfo{icell}.CoordIndex(end-1); % defines (unique)index for the variable representing unstructured y coordinate (default =[]) 682 694 ivar_C=[]; 683 if isfield(CellInfo{icell},'VarIndex_scalar') 684 ivar_C=[ivar_C CellInfo{icell}.VarIndex_scalar]; 685 end 686 if isfield(CellInfo{icell},'VarIndex_image') 687 ivar_C=[ivar_C CellInfo{icell}.VarIndex_image]; 688 end 689 if isfield(CellInfo{icell},'VarIndex_color') 690 ivar_C=[ivar_C CellInfo{icell}.VarIndex_color]; 691 end 692 if isfield(CellInfo{icell},'VarIndex_ancillary') 693 ivar_C=[ivar_C CellInfo{icell}.VarIndex_ancillary]; 694 end 695 if numel(ivar_C)>1 696 errormsg= 'error in plot_field: too many scalar inputs'; 697 return 698 end 695 ListFields=fields(CellInfo{icell}); 696 for ilist=1:numel(ListFields) 697 if ismember(ListFields{ilist},{'VarIndex_scalar','VarIndex_image','VarIndex_color','VarIndex_ancillary'}) 698 ivar_C=CellInfo{icell}.(ListFields{ilist}); 699 break % do not allow more than one scalar 700 end 701 end 699 702 ivar_F=[]; 700 703 if isfield(CellInfo{icell},'VarIndex_warnflag') … … 734 737 end 735 738 if isfield(PlotParam.Vectors,'ColorScalar') && ~isempty(PlotParam.Vectors.ColorScalar) 736 [VarVal, ListVarName,VarAttribute,errormsg]=calc_field_interp([],Data,PlotParam.Vectors.ColorScalar);739 [VarVal,~,~,errormsg]=calc_field_interp([],Data,PlotParam.Vectors.ColorScalar); 737 740 if ~isempty(VarVal) 738 741 vec_C=reshape(VarVal{1},1,numel(VarVal{1})); … … 745 748 if ~isempty(ivar_F)%~(isfield(PlotParam.Vectors,'HideWarning')&& isequal(PlotParam.Vectors.HideWarning,1)) 746 749 vec_F=Data.(Data.ListVarName{ivar_F}); % warning flags for dubious vectors 747 vec_FF( find(vec_F==-2))=1;%setalseFlag to 1(edge of the search box)750 vec_FF(vec_F==-2)=1;%set FalseFlag to 1(edge of the search box) 748 751 end 749 752 end … … 790 793 DCoord_y_min=min(DCoord_y); 791 794 DCoord_y_max=max(DCoord_y); 792 if sign(DCoord_y_min)~=sign(DCoord_y_max) ;% =1 for increasing values, 0 otherwise795 if sign(DCoord_y_min)~=sign(DCoord_y_max)% =1 for increasing values, 0 otherwise 793 796 errormsg=['errror in plot_field.m: non monotonic dimension variable ' YName ]; 794 797 return … … 877 880 if isfield(PlotParam.Scalar,'CheckBW') && ~isempty(PlotParam.Scalar.CheckBW) 878 881 ColorMap=PlotParam.Scalar.CheckBW;%PlotParam.Scalar.CheckBW is char string indicating the colormap type 879 elseif ((siz==2) && (isa(A,'uint8')|| isa(A,'uint16')))% non color images represented in gray scale by default882 elseif siz==2 && (isa(A,'uint8')||isa(A,'uint16'))% non color images represented in gray scale by default 880 883 ColorMap='grayscale'; 881 884 end … … 962 965 % fill the space between contours if opacity is undefined or =1 963 966 if isequal(Opacity,1) 964 [ var,hcontour]=contour(haxes,x_cont,y_cont,A,cont_pos);% determine all contours967 [~,hcontour]=contour(haxes,x_cont,y_cont,A,cont_pos);% determine all contours 965 968 set(hcontour,'Fill','on')% fill the space between contours 966 969 set(hcontour,'LineStyle','none') 967 970 hold on 968 971 end 969 [ var_p,hcontour_p]=contour(haxes,x_cont,y_cont,A,cont_pos_plus,'k-');% draw the contours for positive values as solid lines972 [~,~]=contour(haxes,x_cont,y_cont,A,cont_pos_plus,'k-');% draw the contours for positive values as solid lines 970 973 hold on 971 [ var_m,hcontour_m]=contour(haxes,x_cont,y_cont,A,cont_pos_min,'--');% draw the contours for negative values as dashed lines974 [~,hcontour_m]=contour(haxes,x_cont,y_cont,A,cont_pos_min,'--');% draw the contours for negative values as dashed lines 972 975 if isequal(Opacity,1) 973 976 set(hcontour_m,'LineColor',[1 1 1])% draw negative contours in white (better visibility in dark background) … … 977 980 978 981 %determine the color scale and map 979 c axis([abscontmin abscontmax])982 clim([abscontmin abscontmax]) 980 983 if strcmp(ColorMap,'grayscale') 981 984 vec=linspace(0,1,(abscontmax-abscontmin)/interval);%define a greyscale colormap with steps interval … … 1005 1008 A=uint8(255*double(A)/double(MaxA)); 1006 1009 end 1007 %otherwise1008 %colormap(ColorMap);1010 otherwise 1011 colormap(ColorMap); 1009 1012 end 1010 1013 … … 1088 1091 end 1089 1092 if length(PosColorbar)==4 1090 set(hcol,'Position',PosColorbar) 1093 % set(hcol,'Units','pixel') 1094 set(hcol,'Position',PosColorbar) 1091 1095 end 1092 1096 %YTick=0;%default … … 1126 1130 end 1127 1131 else%no scalar plot 1128 if ~isempty(hima) &&ishandle(hima)1132 if ishandle(hima) 1129 1133 delete(hima) 1130 1134 end 1131 if ~isempty(PosColorbar) && ~isempty(hcol) && ishandle(hcol)1135 if ~isempty(PosColorbar) && ~isempty(hcol) && ishandle(hcol) 1132 1136 delete(hcol) 1133 1137 end … … 1217 1221 % take flags into account: add flag colors to the list of colors 1218 1222 nbcolor=size(colorlist,1); 1219 % % % if test_black1220 % % % nbcolor=nbcolor+1;1221 % % % colorlist(nbcolor,:)=[0 0 0]; %add black to the list of colors1222 % % % if ~isempty(ivar_FF_vec)1223 % % % col_vec(vec_F~=1 & vec_F~=0 & vec_FF==0)=nbcolor;1224 % % % else1225 % % % col_vec(vec_F~=1 & vec_F~=0)=nbcolor;1226 % % % end1227 % % % end1228 1223 nbcolor=nbcolor+1; 1229 1224 if ~isempty(ivar_FF_vec) … … 1349 1344 arrowplus=rot*[uc;vc]; 1350 1345 arrowmoins=rot'*[uc;vc]; 1351 % x1=xc+uc/2-arrowplus(1,:);1352 % x2=xc+uc/2;1353 % x3=xc+uc/2-arrowmoins(1,:);1354 % y1=yc+vc/2-arrowplus(2,:);1355 % y2=yc+vc/2;1356 % y3=yc+vc/2-arrowmoins(2,:);1357 1346 x1=xc+uc-arrowplus(1,:); 1358 1347 x2=xc+uc; … … 1366 1355 matyar=reshape(matyar,1,4*n(2)); 1367 1356 %draw the line or modify the existing ones 1368 % tri=reshape(1:3*length(uc),3,[])';1369 1357 isn=isnan(colorlist(icolor,:));%test if color NaN 1370 1358 if 2*icolor > sizh(1) %if icolor exceeds the number of existing ones … … 1432 1420 diffy=diff(vec_Y); %difference dy=vec_Y(i+1)-vec_Y(i) 1433 1421 index=find(diffy);% find the indices of vec_Y after wich a change of horizontal line occurs(diffy non zero) 1434 if isempty(index); msgbox_uvmat('ERROR','points aligned along abscissa in proj_grid.m'); return; end ;%points aligned% A FAIRE: switch to line plot.1422 if isempty(index); msgbox_uvmat('ERROR','points aligned along abscissa in proj_grid.m'); return; end%points aligned% A FAIRE: switch to line plot. 1435 1423 diff2=diff(diffy(index));% diff2 = fluctuations of the detected vertical grid mesh dy 1436 1424 if max(abs(diff2))>0.001*abs(diffy(index(1))) % if max(diff2) is larger than 1/1000 of the first mesh dy … … 1489 1477 end 1490 1478 if test_interp==1%if we interpolate 1491 xi= [rangx(1):(rangx(2)-rangx(1))/(npxy(2)-1):rangx(2)];1492 yi= [rangy(1):(rangy(2)-rangy(1))/(npxy(1)-1):rangy(2)];1479 xi=rangx(1):(rangx(2)-rangx(1))/(npxy(2)-1):rangx(2); 1480 yi=rangy(1):(rangy(2)-rangy(1))/(npxy(1)-1):rangy(2); 1493 1481 [XI,YI]=meshgrid(xi,yi); 1494 1482 A = interp2(X,Y,B,XI,YI);
Note: See TracChangeset
for help on using the changeset viewer.
