Changeset 72 for trunk/src/plot_field.m


Ignore:
Timestamp:
Mar 30, 2010, 11:03:42 AM (14 years ago)
Author:
sommeria
Message:

ima2vol: write image volumes in 16 bits (test for civ_3D)
plot-text removed: put as a sub-function of plot_field
uvmat: movie stops in case of error in reding files
bug fixes for reading 3D vel fields

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plot_field.m

    r71 r72  
    1212%  dimension variables (case of matrices).
    1313%
    14 % function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,KeepLim,PosColorbar)
     14% function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,htext,PosColorbar)
    1515%
    1616% OUPUT:
     
    5353%
    5454%   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
    5557%            --scalars--
    5658%    .Scalar.MaxA: upper bound (saturation color) for the scalar representation, max(field) by default
     
    7981%    .Vectors.MaxC = imposed maximum of the scalar field used for vector color;
    8082%
    81 % KeepLim:=0 (default) adjust axes limit to the X,Y data, =1: preserves the previous axes limits
     83%
    8284% PosColorbar: if not empty, display a colorbar for B&W images
    8385%               imposed position of the colorbar (ex [0.821 0.471 0.019 0.445])
     
    99101%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    100102
    101 function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,KeepLim,PosColorbar)
    102 
     103function [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 
    103108%default output
    104109if ~exist('PlotParam','var'),PlotParam=[];end;
    105 if ~exist('KeepLim','var'),KeepLim=0;end;
     110if ~exist('htext','var'),htext=[];end;
    106111if ~exist('PosColorbar','var'),PosColorbar=[];end;
    107112PlotType='text'; %default
     
    177182    [Data.NbDim,imax]=max(NbDim);
    178183end
    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);
     184if isequal(Data.NbDim,0)
     185        AxeData=plot_text(Data,htext);
    182186        PlotType='text';
    183 %     else
    184 %         [AxeData,haxes]=plot_hist(Data,haxes,PlotParam);
    185 %     end
    186187elseif isequal(Data.NbDim,1)
    187188    [AxeData,haxes]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);%
     
    198199        return
    199200    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);
    201202    if testzoomaxes
    202203        [AxeData,zoomaxes,PlotParamOut]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar);
     
    235236
    236237
    237 %----------------------------------------------------------
     238%-------------------------------------------------------------------
     239function hdisplay=plot_text(FieldData,hdisplay_in)
     240%-------------------------------------------------------------------
     241if exist('hdisplay_in','var') & ishandle(hdisplay_in) & isequal(get(hdisplay_in,'Type'),'uicontrol')
     242    hdisplay=hdisplay_in;
     243else
     244    figure;%create new figure
     245    hdisplay=uicontrol('Style','edit', 'Units','normalized','Position', [0 0 1 1],'Max',2,'FontName','monospaced');
     246end
     247   
     248ff=fields(FieldData);%list of field names
     249vv=struct2cell(FieldData);%list of field values
     250
     251for 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};
     293end
     294Tabchar=cell2tab(Tabcell,': ');
     295set(hdisplay,'String', Tabchar)
     296
     297
     298%-------------------------------------------------------------------
    238299function [AxeData,haxes]=plot_profile(data,CellVarIndex,VarType,haxes,PlotParam)
    239 %-----------------------------------------------------------
     300%-------------------------------------------------------------------
    240301%axes(haxes)
    241302hfig=get(haxes,'parent');
     
    247308    set(haxes,'NextPlot',PlotParam.NextPlot)
    248309end
    249 % adjust the size of the plot to include the whole field, except if KeepLim=1
     310% adjust the size of the plot to include the whole field,
    250311if isfield(PlotParam,'FixedLimits') && isequal(PlotParam.FixedLimits,1)  %adjust the graph limits*
    251312    set(haxes,'XLimMode', 'manual')
     
    454515
    455516
    456 %---------------------------------------
    457 % plot_plane
    458 %----------------------------------------
    459 function [AxeData,haxes,PlotParamOut,PlotType]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,KeepLim,PosColorbar)
     517%-------------------------------------------------------------------
     518function [AxeData,haxes,PlotParamOut,PlotType]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,htext,PosColorbar)
     519%-------------------------------------------------------------------
    460520grid(haxes, 'off')
    461521%default plotting parameters
     
    854914    vec_U=reshape(vec_U,1,numel(vec_U));
    855915    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)
    858918    AxeData.Mesh=sqrt((MinMaxX*MinMaxY)/length(vec_X));
    859919    if  ~isfield(PlotParam.Vectors,'AutoVec') || isequal(PlotParam.Vectors.AutoVec,0)|| ~isfield(PlotParam.Vectors,'VecScale')...
     
    9931053end
    9941054
    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
     1056if ~(isfield(PlotParam,'FixedLimits') && PlotParam.FixedLimits)
     1057    %~(exist('KeepLim','var') && isequal(KeepLim,1))  %adjust the graph limits*
    9971058        test_lim=0;
    9981059        if test_vec
     
    10281089set(get(haxes,'XLabel'),'String',[XName x_units]);
    10291090set(get(haxes,'YLabel'),'String',[YName y_units]);
    1030 %---------------------------------------------
    1031 %function for plotting vectors
    1032 %------------------------------------------------
     1091
     1092%-------------------------------------------------------------------
     1093% --- function for plotting vectors
    10331094%INPUT:
    10341095% haxes: handles of the plotting axes
     
    10381099%col_vec: matlab vector setting the color number #i for each velocity vector
    10391100function quiresetn(haxes,x,y,u,v,scale,colorlist,col_vec)
    1040 
     1101%-------------------------------------------------------------------
    10411102%define arrows
    10421103theta=0.5 ;%angle arrow
     
    11181179end
    11191180
    1120 %---------------------------------------
    1121 %determine tick positions for colorbar
    1122 %------------------------------------
     1181%-------------------------------------------------------------------
     1182% ---- determine tick positions for colorbar
    11231183function YTick=colbartick(MinA,MaxA)
     1184%-------------------------------------------------------------------
    11241185%determine tick positions with "simple" values between MinA and MaxA
    11251186YTick=0;%default
Note: See TracChangeset for help on using the changeset viewer.