Changeset 72 for trunk/src/plot_field.m
- Timestamp:
- Mar 30, 2010, 11:03:42 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plot_field.m
r71 r72 12 12 % dimension variables (case of matrices). 13 13 % 14 % function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam, KeepLim,PosColorbar)14 % function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,htext,PosColorbar) 15 15 % 16 16 % OUPUT: … … 53 53 % 54 54 % PlotParam: parameters for plotting, as read on the uvmat interface (by function 'read_plot_param.m') 55 % .FixedLimits:=0 (default) adjust axes limit to the X,Y data, =1: preserves the previous axes limits 56 % .Auto_xy: =0 (default): kepp 1 to 1 aspect ratio for x and y scales, =1: automatic adjustment of the graph 55 57 % --scalars-- 56 58 % .Scalar.MaxA: upper bound (saturation color) for the scalar representation, max(field) by default … … 79 81 % .Vectors.MaxC = imposed maximum of the scalar field used for vector color; 80 82 % 81 % KeepLim:=0 (default) adjust axes limit to the X,Y data, =1: preserves the previous axes limits83 % 82 84 % PosColorbar: if not empty, display a colorbar for B&W images 83 85 % imposed position of the colorbar (ex [0.821 0.471 0.019 0.445]) … … 99 101 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 100 102 101 function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,KeepLim,PosColorbar) 102 103 function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,htext,PosColorbar) 104 % TODO: 105 % use htext: handles of the text edit box (uicontrol) 106 % introduce PlotParam.Hold: 'on' or 'off' (for curves) 107 103 108 %default output 104 109 if ~exist('PlotParam','var'),PlotParam=[];end; 105 if ~exist(' KeepLim','var'),KeepLim=0;end;110 if ~exist('htext','var'),htext=[];end; 106 111 if ~exist('PosColorbar','var'),PosColorbar=[];end; 107 112 PlotType='text'; %default … … 177 182 [Data.NbDim,imax]=max(NbDim); 178 183 end 179 if isequal(Data.NbDim,0) % TODO: chech whether this function is still used, replace by plot_profile ? 180 % if isfield(Data,'Style') & isequal(Data.Style,'points') 181 AxeData=plot_text(Data,haxes); 184 if isequal(Data.NbDim,0) 185 AxeData=plot_text(Data,htext); 182 186 PlotType='text'; 183 % else184 % [AxeData,haxes]=plot_hist(Data,haxes,PlotParam);185 % end186 187 elseif isequal(Data.NbDim,1) 187 188 [AxeData,haxes]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);% … … 198 199 return 199 200 end 200 [AxeData,haxes,PlotParamOut,PlotType]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),haxes,PlotParam, KeepLim,PosColorbar);201 [AxeData,haxes,PlotParamOut,PlotType]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),haxes,PlotParam,htext,PosColorbar); 201 202 if testzoomaxes 202 203 [AxeData,zoomaxes,PlotParamOut]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar); … … 235 236 236 237 237 %---------------------------------------------------------- 238 %------------------------------------------------------------------- 239 function hdisplay=plot_text(FieldData,hdisplay_in) 240 %------------------------------------------------------------------- 241 if exist('hdisplay_in','var') & ishandle(hdisplay_in) & isequal(get(hdisplay_in,'Type'),'uicontrol') 242 hdisplay=hdisplay_in; 243 else 244 figure;%create new figure 245 hdisplay=uicontrol('Style','edit', 'Units','normalized','Position', [0 0 1 1],'Max',2,'FontName','monospaced'); 246 end 247 248 ff=fields(FieldData);%list of field names 249 vv=struct2cell(FieldData);%list of field values 250 251 for icell=1:length(vv) 252 Tabcell{icell,1}=ff{icell}; 253 ss=vv{icell}; 254 sizss=size(ss); 255 if isnumeric(ss) 256 if sizss(1)<=1 & length(ss)<5 257 displ{icell}=num2str(ss); 258 else 259 displ{icell}=[class(ss) ', size ' num2str(size(ss))]; 260 end 261 elseif ischar(ss) 262 displ{icell}=ss; 263 elseif iscell(ss) 264 sizcell=size(ss); 265 if sizcell(1)==1 & length(sizcell)==2 %line cell 266 ssline='{'''; 267 for icolumn=1:sizcell(2) 268 if isnumeric(ss{icolumn}) 269 if size(ss{icolumn},1)<=1 & length(ss{icolumn})<5 270 sscolumn=num2str(ss{icolumn});%line vector 271 else 272 sscolumn=[class(ss{icolumn}) ', size ' num2str(size(ss{icolumn}))]; 273 end 274 elseif ischar(ss{icolumn}) 275 sscolumn=ss{icolumn}; 276 else 277 sscolumn=class(ss{icolumn}); 278 end 279 if icolumn==1 280 ssline=[ssline sscolumn]; 281 else 282 ssline=[ssline ''',''' sscolumn]; 283 end 284 end 285 displ{icell}=[ssline '''}']; 286 else 287 displ{icell}=[class(ss) ', size ' num2str(sizcell)]; 288 end 289 else 290 displ{icell}=class(ss); 291 end 292 Tabcell{icell,2}=displ{icell}; 293 end 294 Tabchar=cell2tab(Tabcell,': '); 295 set(hdisplay,'String', Tabchar) 296 297 298 %------------------------------------------------------------------- 238 299 function [AxeData,haxes]=plot_profile(data,CellVarIndex,VarType,haxes,PlotParam) 239 %----------------------------------------------------------- 300 %------------------------------------------------------------------- 240 301 %axes(haxes) 241 302 hfig=get(haxes,'parent'); … … 247 308 set(haxes,'NextPlot',PlotParam.NextPlot) 248 309 end 249 % adjust the size of the plot to include the whole field, except if KeepLim=1310 % adjust the size of the plot to include the whole field, 250 311 if isfield(PlotParam,'FixedLimits') && isequal(PlotParam.FixedLimits,1) %adjust the graph limits* 251 312 set(haxes,'XLimMode', 'manual') … … 454 515 455 516 456 %--------------------------------------- 457 % plot_plane 458 %---------------------------------------- 459 function [AxeData,haxes,PlotParamOut,PlotType]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,KeepLim,PosColorbar) 517 %------------------------------------------------------------------- 518 function [AxeData,haxes,PlotParamOut,PlotType]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,htext,PosColorbar) 519 %------------------------------------------------------------------- 460 520 grid(haxes, 'off') 461 521 %default plotting parameters … … 854 914 vec_U=reshape(vec_U,1,numel(vec_U)); 855 915 vec_V=reshape(vec_V,1,numel(vec_V)); 856 MinMaxX=max(vec_X)-min(vec_X) ;857 MinMaxY=max(vec_Y)-min(vec_Y) ;916 MinMaxX=max(vec_X)-min(vec_X) 917 MinMaxY=max(vec_Y)-min(vec_Y) 858 918 AxeData.Mesh=sqrt((MinMaxX*MinMaxY)/length(vec_X)); 859 919 if ~isfield(PlotParam.Vectors,'AutoVec') || isequal(PlotParam.Vectors.AutoVec,0)|| ~isfield(PlotParam.Vectors,'VecScale')... … … 993 1053 end 994 1054 995 % adjust the size of the plot to include the whole field, except if KeepLim=1 996 if ~(exist('KeepLim','var') && isequal(KeepLim,1)) %adjust the graph limits* 1055 % adjust the size of the plot to include the whole field, except if PlotParam.FixedLimits=1 1056 if ~(isfield(PlotParam,'FixedLimits') && PlotParam.FixedLimits) 1057 %~(exist('KeepLim','var') && isequal(KeepLim,1)) %adjust the graph limits* 997 1058 test_lim=0; 998 1059 if test_vec … … 1028 1089 set(get(haxes,'XLabel'),'String',[XName x_units]); 1029 1090 set(get(haxes,'YLabel'),'String',[YName y_units]); 1030 %--------------------------------------------- 1031 % function for plotting vectors1032 % ------------------------------------------------1091 1092 %------------------------------------------------------------------- 1093 % --- function for plotting vectors 1033 1094 %INPUT: 1034 1095 % haxes: handles of the plotting axes … … 1038 1099 %col_vec: matlab vector setting the color number #i for each velocity vector 1039 1100 function quiresetn(haxes,x,y,u,v,scale,colorlist,col_vec) 1040 1101 %------------------------------------------------------------------- 1041 1102 %define arrows 1042 1103 theta=0.5 ;%angle arrow … … 1118 1179 end 1119 1180 1120 %--------------------------------------- 1121 %determine tick positions for colorbar 1122 %------------------------------------ 1181 %------------------------------------------------------------------- 1182 % ---- determine tick positions for colorbar 1123 1183 function YTick=colbartick(MinA,MaxA) 1184 %------------------------------------------------------------------- 1124 1185 %determine tick positions with "simple" values between MinA and MaxA 1125 1186 YTick=0;%default
Note: See TracChangeset
for help on using the changeset viewer.