Changeset 193 for trunk/src/plot_field.m
- Timestamp:
- Feb 20, 2011, 10:42:19 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plot_field.m
r192 r193 134 134 if testnewfig 135 135 hfig=figure; 136 % if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1)137 % set(hfig,'UserData',PlotParam)138 % end139 136 set(hfig,'Units','normalized') 140 % set(hfig,'WindowButtonDownFcn','mouse_down')141 % set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action function142 % set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse action function143 137 haxes=axes; 144 138 set(haxes,'position',[0.13,0.2,0.775,0.73]) … … 161 155 %% check the cells of fields : 162 156 [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data); 163 164 157 if ~isempty(errormsg) 165 158 msgbox_uvmat('ERROR',['input of plot_field/find_field_indices: ' errormsg]); … … 202 195 errormsg=[]; 203 196 AxeData=get(haxes,'UserData'); 197 if isempty(index_2D) 198 plot_plane([],[],[],haxes);%removes images or vector plots if any 199 else 200 [xx,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),haxes,PlotParam,PosColorbar); 201 AxeData.NbDim=2; 202 if testzoomaxes && isempty(errormsg) 203 [zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),zoomaxes,PlotParam,PosColorbar); 204 AxeData.ZoomAxes=zoomaxes; 205 end 206 %remove coordinates variables from 1D plot 207 for ivar=1:length(index_1D) 208 if isequal(CellVarIndex{index_1D(ivar)},VarType{index_1D(ivar)}.coord) 209 index_1D(ivar)=0; 210 end 211 end 212 index_1D=find(index_1D); 213 end 214 204 215 if isempty(index_1D) 205 216 plot_profile([],[],[],haxes);% … … 211 222 end 212 223 PlotType='line'; 213 end214 215 if isempty(index_2D)216 plot_plane([],[],[],haxes);%removes images or vector plots if any217 else218 [xx,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),haxes,PlotParam,PosColorbar);219 AxeData.NbDim=2;220 if testzoomaxes && isempty(errormsg)221 [zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),zoomaxes,PlotParam,PosColorbar);222 AxeData.ZoomAxes=zoomaxes;223 end224 224 end 225 225 htext=findobj(hfig,'Tag','text_display'); … … 374 374 else 375 375 coord_x_index_cell=VarType{icell}.coord(1); 376 376 if isequal(coord_x_index_cell,0) 377 377 continue % the cell has no abscissa, skip it 378 end 379 % if ~isempty(coord_x_index)&&~isequal(coord_x_index_cell,coord_x_index) 380 % %continue %all the selected variables must have the same first dimension 381 % else 382 % coord_x_index=coord_x_index_cell; 383 % end 384 coord_x_index=coord_x_index_cell; 378 end 379 coord_x_index=coord_x_index_cell; 385 380 end 386 381 testplot=ones(size(data.ListVarName));%default test for plotted variables … … 393 388 end 394 389 eval(['coord_x{icell}=data.' data.ListVarName{coord_x_index} ';']);%coordinate variable set as coord_x 390 XMin(icell)=min(coord_x{icell}); 391 XMax(icell)=max(coord_x{icell}); 395 392 testplot(coord_x_index)=0; 396 393 if ~isempty(VarType{icell}.ancillary') … … 425 422 end 426 423 eval(['data.' VarName '=squeeze(data.' VarName ');']) 424 eval(['YMin(ivar)=min(data.' VarName ');']) 425 eval(['YMax(ivar)=max(data.' VarName ');']) 427 426 plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot_0 ',']; 428 427 eval(['nbcomponent2=size(data.' VarName ',2);']); … … 431 430 coord_x{icell}=linspace(coord_x{icell}(1),coord_x{icell}(2),nbcomponent1); 432 431 end 433 %eval(['varmean=mean(double(data.' VarName '));']);%mean value434 %textmean=[textmean; {[VarName 'mean= ' num2str(varmean,4)]}];435 432 if nbcomponent1==1|| nbcomponent2==1 436 433 legend_str=[legend_str {VarName}]; %variable with one component … … 442 439 end 443 440 end 441 YMin_cell(icell)=min(YMin); 442 YMax_cell(icell)=max(YMax); 444 443 end 445 444 … … 447 446 if test_newplot && ~isequal(plotstr,'hhh=plot(') 448 447 set(hfig,'CurrentAxes',haxes) 449 tag=get(haxes,'tag'); 450 448 tag=get(haxes,'tag'); 451 449 %%% 452 450 plotstr=[plotstr '''tag'',''plot_line'');']; 453 451 eval(plotstr) %execute plot (instruction plotstr) 454 452 %%% 455 456 453 set(haxes,'tag',tag) 457 454 grid(haxes, 'on') … … 499 496 end 500 497 498 %% determine axes bounds 499 fix_lim=isfield(PlotParam,'FixLimits') && PlotParam.FixLimits; 500 if fix_lim 501 if ~isfield(PlotParam,'MinX')||~isfield(PlotParam,'MaxX')||~isfield(PlotParam,'MinY')||~isfield(PlotParam,'MaxY') 502 fix_lim=0; %free limits if lits are not set, 503 end %else PlotParamOut.XMin =PlotParam.XMin... 504 end 505 if ~fix_lim 506 PlotParamOut.MinX=min(XMin); 507 PlotParamOut.MaxX=max(XMax); 508 PlotParamOut.MinY=min(YMin_cell); 509 PlotParamOut.MaxY=max(YMax_cell); 510 end 501 511 502 512 %------------------------------------------------------------------- … … 521 531 hcol=findobj(hfig,'Tag','Colorbar'); %look for colorbar axes 522 532 hima=findobj(haxes,'Tag','ima');% search existing image in the current axes 523 errormsg= [];%default533 errormsg='';%default 524 534 test_ima=0; %default: test for image or map plot 525 535 test_vec=0; %default: test for vector plots … … 661 671 end 662 672 if test_interp_X 663 npxy( 1)=max([256 floor((AX(end)-AX(1))/DAX_min) floor((AX(end)-AX(1))/DAX_max)]);673 npxy(2)=max([256 floor((AX(end)-AX(1))/DAX_min) floor((AX(end)-AX(1))/DAX_max)]); 664 674 xI=linspace(AX(1),AX(end),npxy(2)); 665 675 if ~test_interp_Y … … 1033 1043 1034 1044 %store the coordinate extrema occupied by the field 1035 Data1036 1045 if ~isempty(Data) 1037 1046 fix_lim=isfield(PlotParam,'FixLimits') && PlotParam.FixLimits; … … 1041 1050 end %else PlotParamOut.XMin =PlotParam.XMin... 1042 1051 end 1043 'TESTfix'1044 fix_lim1045 1052 if ~fix_lim 1046 1053 XMin=[]; … … 1110 1117 rot=alpha*[cos(theta) -sin(theta); sin(theta) cos(theta)]'; 1111 1118 %find the existing lines 1112 %h=findobj(gca,'Type','Line');% search existing lines in the current axes1113 1119 h=findobj(haxes,'Tag','vel');% search existing lines in the current axes 1114 1120 sizh=size(h); 1115 1121 set(h,'EraseMode','xor'); 1116 1122 set(haxes,'NextPlot','replacechildren'); 1117 1123 1118 1124 %drawnow 1119 1125 %create lines (if no lines) or modify them … … 1125 1131 1126 1132 for icolor=1:ncolor 1127 %determine the line positions for each color icolor 1133 %determine the line positions for each color icolor 1128 1134 ind=find(col_vec==icolor); 1129 1135 xc=x(ind); … … 1134 1140 xN=NaN*ones(size(xc)); 1135 1141 matx=[xc(:)-uc(:)/2 xc(:)+uc(:)/2 xN(:)]'; 1136 % matx=[xc(:) xc(:)+uc(:) xN(:)]';1142 % matx=[xc(:) xc(:)+uc(:) xN(:)]'; 1137 1143 matx=reshape(matx,1,3*n(2)); 1138 1144 maty=[yc(:)-vc(:)/2 yc(:)+vc(:)/2 xN(:)]'; 1139 % maty=[yc(:) yc(:)+vc(:) xN(:)]';1145 % maty=[yc(:) yc(:)+vc(:) xN(:)]'; 1140 1146 maty=reshape(maty,1,3*n(2)); 1141 1147 … … 1149 1155 y2=yc+vc/2; 1150 1156 y3=yc+vc/2-arrowmoins(2,:); 1151 % x1=xc+uc-arrowplus(1,:);1152 % x2=xc+uc;1153 % x3=xc+uc-arrowmoins(1,:);1154 % y1=yc+vc-arrowplus(2,:);1155 % y2=yc+vc;1156 % y3=yc+vc-arrowmoins(2,:);1157 1157 matxar=[x1(:) x2(:) x3(:) xN(:)]'; 1158 1158 matxar=reshape(matxar,1,4*n(2)); … … 1160 1160 matyar=reshape(matyar,1,4*n(2)); 1161 1161 %draw the line or modify the existing ones 1162 % hx = [x1;x2;x3]; 1163 % hy = [y1;y2;y3]; 1164 tri=reshape(1:3*length(uc),3,[])'; 1165 %d = tri(:,[1 2 3 1])'; 1166 1162 tri=reshape(1:3*length(uc),3,[])'; 1167 1163 isn=isnan(colorlist(icolor,:));%test if color NaN 1168 1164 if 2*icolor > sizh(1) %if icolor exceeds the number of existing ones 1169 %axes(haxes)1170 % hfig=get(haxes,'parent');1171 % axes(haxes)1172 % set(0,'CurrentFigure',hfig)1173 % set(hfig,'CurrentAxes',haxes)1174 1165 if ~isn(1) %if the vectors are visible color not nan 1175 1166 if n(2)>0 … … 1177 1168 line(matx,maty,'Color',colorlist(icolor,:),'Tag','vel');% plot new lines 1178 1169 line(matxar,matyar,'Color',colorlist(icolor,:),'Tag','vel');% plot arrows 1179 % fill(hx(d),hy(d),colorlist(icolor,:),'EdgeColor','none',' 1180 % Tag','Vel'); 1181 end 1170 end 1182 1171 end 1183 1172 else 1184 if isn(1) 1173 if isn(1) 1185 1174 delete(h(2*icolor-1)) 1186 1175 delete(h(2*icolor)) … … 1193 1182 set(h(2*icolor),'EraseMode','xor'); 1194 1183 end 1195 1184 end 1196 1185 end 1197 1186 if sizh(1) > 2*ncolor
Note: See TracChangeset
for help on using the changeset viewer.