Changeset 292 for trunk/src/plot_field.m


Ignore:
Timestamp:
Nov 21, 2011, 11:12:06 AM (9 years ago)
Author:
sommeria
Message:

GUI civ patch2 corrected (SmoothingParam?).
uvmatand view_field updated with panels.
read_plot_param removed (replaced by the mostgeneral read_GUI)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plot_field.m

    r252 r292  
    44%  This function is used by uvmat to plot fields. It automatically chooses the representation
    55% appropriate to the input field structure:
    6 %     2D vector fields are represented by arrows, 2D scalar fiedlds by grey scale images or contour plots, 1D fields are represented by usual plot with (abscissa, ordinate).
     6%     2D vector fields are represented by arrows, 2D scalar fields by grey scale images or contour plots, 1D fields are represented by usual plot with (abscissa, ordinate).
    77%  The input field structure is first tested by check_field_structure.m,
    88%  then split into blocks of related variables  by find_field_indices.m.
    9 %  The dimensionality of each block is obtained  by this fuction
     9%  The dimensionality of each block is obtained  by this function
    1010%  considering the presence of variables with the attribute .Role='coord_x'
    1111%  and/or coord_y and/or coord_z (case of unstructured coordinates), or
     
    5252%   haxes: handle of the plotting axes to update with the new plot. If this input is absent or not a valid axes handle, a new figure is created.
    5353%
    54 %   PlotParam: parameters for plotting, as read on the uvmat interface (by function 'read_plot_param.m')
    55 %     .FixLimits:=0 (default) adjust axes limit to the X,Y data, =1: preserves the previous axes limits
    56 %     .FixEqual: =0 (default):automatic adjustment of the graph, keep 1 to 1 aspect ratio for x and y scales.
     54%   PlotParam: parameters for plotting, as read on the uvmat or view_field interface (by function 'read_GUI.m')
     55%     .Coordinates.CheckFixLimits:=0 (default) adjust axes limit to the X,Y data, =1: preserves the previous axes limits
     56%     .Coordinates.CheckFixEqual: =0 (default):automatic adjustment of the graph, keep 1 to 1 aspect ratio for x and y scales.
    5757%            --scalars--
    5858%    .Scalar.MaxA: upper bound (saturation color) for the scalar representation, max(field) by default
    5959%    .Scalar.MinA: lower bound (saturation) for the scalar representation, min(field) by default
    60 %    .Scalar.FixScal: =0 (default) lower and upper bounds of the scalar representation set to the min and max of the field
     60%    .Scalar.CheckFixScal: =0 (default) lower and upper bounds of the scalar representation set to the min and max of the field
    6161%               =1 lower and upper bound imposed by .AMax and .MinA
    62 %    .Scalar.BW= 1 black and white representation imposed, =0 by default.
    63 %    .Scalar.Contours= 1: represent scalars by contour plots (Matlab function 'contour'); =0 by default
     62%    .Scalar.CheckBW= 1 black and white representation imposed, =0 by default.
     63%    .Scalar.CheckContours= 1: represent scalars by contour plots (Matlab function 'contour'); =0 by default
    6464%    .IncrA : contour interval
    6565%            -- vectors--
    6666%    .Vectors.VecScale: scale for the vector representation
    67 %    .Vectors.FixVec: =0 (default) automatic length for vector representation, =1: length set by .VecScale
    68 %    .Vectors.HideFalse= 0 (default) false vectors represented in magenta, =1: false vectors not represented;
    69 %    .Vectors.HideWarning= 0 (default) vectors marked by warnflag~=0 marked in black, 1: no warning representation;
    70 %    .Vectors.decimate4 = 0 (default) all vectors reprtesented, =1: half of  the vectors represented along each coordinate
     67%    .Vectors.CheckFixVec: =0 (default) automatic length for vector representation, =1: length set by .VecScale
     68%    .Vectors.CheckHideFalse= 0 (default) false vectors represented in magenta, =1: false vectors not represented;
     69%    .Vectors.CheckHideWarning= 0 (default) vectors marked by warnflag~=0 marked in black, 1: no warning representation;
     70%    .Vectors.CheckDecimate4 = 0 (default) all vectors reprtesented, =1: half of  the vectors represented along each coordinate
    7171%         -- vector color--
    7272%    .Vectors.ColorCode= 'black','white': imposed color  (default ='blue')
     
    7777%    .Vectors.colcode1 : first threshold for rgb, first value for'continuous'
    7878%    .Vectors.colcode2 : second threshold for rgb, last value (saturation) for 'continuous'
    79 %    .Vectors.FixedCbounds;  =0 (default): the bounds on C representation are min and max, =1: they are fixed by .Minc and .MaxC
     79%    .Vectors.CheckFixedCbounds;  =0 (default): the bounds on C representation are min and max, =1: they are fixed by .Minc and .MaxC
    8080%    .Vectors.MinC = imposed minimum of the scalar field used for vector color;
    8181%    .Vectors.MaxC = imposed maximum of the scalar field used for vector color;
    8282%
    83 %
    8483% PosColorbar: if not empty, display a colorbar for B&W images
    8584%               imposed position of the colorbar (ex [0.821 0.471 0.019 0.445])
     
    102101
    103102function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,PosColorbar)
    104 % TODO:
    105103% use htext: handles of the text edit box (uicontrol)
    106104% introduce PlotParam.Hold: 'on' or 'off' (for curves)
     
    111109PlotType='text'; %default
    112110PlotParamOut=PlotParam;%default
     111Coordinates=[];
     112if isfield(PlotParam,'Coordinates')
     113Coordinates=PlotParam.Coordinates;
     114end
    113115
    114116%% test axes and figure
     
    175177   
    176178        %% set axes properties
    177     if isfield(PlotParam,'FixLimits') && isequal(PlotParam.FixLimits,1)  %adjust the graph limits*
     179    if isfield(Coordinates,'CheckFixLimits') && isequal(Coordinates.CheckFixLimits,1)  %adjust the graph limits*
    178180        set(haxes,'XLimMode', 'manual')
    179181        set(haxes,'YLimMode', 'manual')
     
    182184        set(haxes,'YLimMode', 'auto')
    183185    end
    184     if ~isfield(PlotParam,'FixEqual')&& isfield(Data,'CoordUnit')
    185         PlotParam.FixEqual=1;
    186     end
    187     if isfield(PlotParam,'FixEqual') && isequal(PlotParam.FixEqual,1)
     186    if ~isfield(Coordinates,'CheckFixEqual')&& isfield(Data,'CoordUnit')
     187        Coordinates.CheckFixEqual=1;
     188    end
     189    if isfield(Coordinates,'CheckFixEqual') && isequal(Coordinates.CheckFixEqual,1)
    188190        set(haxes,'DataAspectRatioMode','manual')
    189191       set(haxes,'DataAspectRatio',[1 1 1])
     
    222224     plot_profile([],[],[],haxes);%
    223225else
    224         PlotParamOut=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),haxes,PlotParam);%
     226        Coordinates=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),haxes,PlotParam.Coordinates);%
    225227        if testzoomaxes
    226             [zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),zoomaxes,PlotParam);
     228            [zoomaxes,Coordinates]=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),zoomaxes,PlotParam.Coordinates);
    227229            AxeData.ZoomAxes=zoomaxes;
     230        end
     231        if ~isempty(Coordinates)
     232            PlotParamOut.Coordinates=Coordinates;
    228233        end
    229234        PlotType='line';
     
    242247end
    243248if isfield(PlotParamOut,'MinX')
    244 %     'TESTplot'
    245 %     haxes
    246 %     PlotParamOut.MinX
    247 %     PlotParamOut.MaxY
    248 %     set(haxes,'XLim',[PlotParamOut.MinX PlotParamOut.MaxX])
    249 %     set(haxes,'YLim',[PlotParamOut.MinY PlotParamOut.MaxY])
    250249    AxeData.RangeX=[PlotParamOut.MinX PlotParamOut.MaxX];%'[PlotParamOut.MinX PlotParamOut.MaxX];
    251250    AxeData.RangeY=[PlotParamOut.MinY PlotParamOut.MaxY];%[PlotParamOut.MinY PlotParamOut.MaxY]
     
    262261    set(hfig,'UserData',FigData)
    263262end
    264              
     263
    265264%-------------------------------------------------------------------
    266265function errormsg=plot_text(FieldData,CellVarIndex,htext)
    267266%-------------------------------------------------------------------
    268 % if exist('hdisplay_in','var') && ~isempty(hdisplay_in) && ishandle(hdisplay_in) && isequal(get(hdisplay_in,'Type'),'uicontrol')
    269 %     hdisplay=hdisplay_in;
    270 % else
    271 %     figure;%create new figure
    272 %     hdisplay=uicontrol('Style','edit', 'Units','normalized','Position', [0 0 1 1],'Max',2,'FontName','monospaced');
    273 % end
    274267errormsg=[];
    275268txt_cell={};
    276269for icell=1:length(CellVarIndex)
    277270    VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list data.ListVarName
    278 % ff=fields(FieldData);%list of field names
    279 % vv=struct2cell(FieldData);%list of field values
    280 %
    281 % for icell=1:length(vv)
    282271    for ivar=1:length(VarIndex)
    283272         VarName=FieldData.ListVarName{VarIndex(ivar)};
    284          eval(['VarValue=FieldData.' VarName ';'])
     273         VarValue=FieldData.(VarName);
    285274         if size(VarValue,1)~=1
    286275             VarValue=VarValue';
     
    290279    end
    291280end
    292 
    293281set(htext,'String',txt_cell)
    294 %     txt_cell=[txt_cell {num2str(
    295 %     Tabcell{icell,1}=ff{icell};
    296 %     ss=vv{icell};
    297 %     sizss=size(ss);
    298 %     if isnumeric(ss)
    299 %         if sizss(1)<=1 && length(ss)<5
    300 %             displ{icell}=num2str(ss);
    301 %         else
    302 %             displ{icell}=[class(ss) ', size ' num2str(size(ss))];
    303 %         end
    304 %     elseif ischar(ss)
    305 %         displ{icell}=ss;
    306 %     elseif iscell(ss)
    307 %         sizcell=size(ss);
    308 %         if sizcell(1)==1 && length(sizcell)==2 %line cell
    309 %            ssline='{''';
    310 %            for icolumn=1:sizcell(2)
    311 %                if isnumeric(ss{icolumn})
    312 %                    if size(ss{icolumn},1)<=1 && length(ss{icolumn})<5
    313 %                       sscolumn=num2str(ss{icolumn});%line vector
    314 %                    else
    315 %                       sscolumn=[class(ss{icolumn}) ', size ' num2str(size(ss{icolumn}))];
    316 %                    end
    317 %                elseif ischar(ss{icolumn})
    318 %                    sscolumn=ss{icolumn};
    319 %                else
    320 %                    sscolumn=class(ss{icolumn});
    321 %                end
    322 %                if icolumn==1
    323 %                    ssline=[ssline sscolumn];
    324 %                else
    325 %                    ssline=[ssline ''',''' sscolumn];
    326 %                end
    327 %            end
    328 %            displ{icell}=[ssline '''}'];
    329 %         else
    330 %            displ{icell}=[class(ss) ', size ' num2str(sizcell)];
    331 %         end
    332 %     else
    333 %         displ{icell}=class(ss);
    334 %     end
    335 %     Tabcell{icell,2}=displ{icell};
    336 % end
    337 % Tabchar=cell2tab(Tabcell,': ');
    338 % set(hdisplay,'String', Tabchar)
    339 
     282set(htext,'UserData',txt_cell)% for storage during mouse display
    340283
    341284%-------------------------------------------------------------------
    342 function PlotParamOut=plot_profile(data,CellVarIndex,VarType,haxes,PlotParam)
     285function CoordinatesOut=plot_profile(data,CellVarIndex,VarType,haxes,Coordinates)
    343286%-------------------------------------------------------------------
    344287
    345 if ~exist('PlotParam','var')
    346     PlotParam=[];
    347 end
    348 PlotParamOut=PlotParam; %default
     288if ~exist('Coordinates','var')
     289    Coordinates=[];
     290end
     291CoordinatesOut=Coordinates; %default
    349292hfig=get(haxes,'parent');
    350293%suppress existing plot isf empty data
     
    361304end
    362305
    363 
    364306ColorOrder=[1 0 0;0 0.5 0;0 0 1;0 0.75 0.75;0.75 0 0.75;0.75 0.75 0;0.25 0.25 0.25];
    365307set(haxes,'ColorOrder',ColorOrder)
    366 if isfield(PlotParam,'NextPlot')
    367     set(haxes,'NextPlot',PlotParam.NextPlot)
     308if isfield(Coordinates,'NextPlot')
     309    set(haxes,'NextPlot',Coordinates.NextPlot)
    368310end
    369311% adjust the size of the plot to include the whole field,
     
    372314
    373315%% prepare the string for plot command
    374 %initiate  the plot command
    375316plotstr='hhh=plot(';
    376 % textmean={};
    377317coord_x_index=[];
    378318xtitle='';
     
    513453
    514454%% determine axes bounds
    515 PlotParamOut.RangeX=[min(XMin) max(XMax)];
    516 PlotParamOut.RangeY=[min(YMin_cell) max(YMax_cell)];
    517 fix_lim=isfield(PlotParam,'FixLimits') && PlotParam.FixLimits;
     455CoordinatesOut.RangeX=[min(XMin) max(XMax)];
     456CoordinatesOut.RangeY=[min(YMin_cell) max(YMax_cell)];
     457fix_lim=isfield(Coordinates,'FixLimits') && Coordinates.FixLimits;
    518458if fix_lim
    519     if ~isfield(PlotParam,'MinX')||~isfield(PlotParam,'MaxX')||~isfield(PlotParam,'MinY')||~isfield(PlotParam,'MaxY')
     459    if ~isfield(Coordinates,'MinX')||~isfield(Coordinates,'MaxX')||~isfield(Coordinates,'MinY')||~isfield(Coordinates,'MaxY')
    520460        fix_lim=0; %free limits if lits are not set,
    521461    end
    522462end
    523463if ~fix_lim
    524     PlotParamOut.MinX=min(XMin);
    525     PlotParamOut.MaxX=max(XMax);
    526     PlotParamOut.MinY=min(YMin_cell);
    527     PlotParamOut.MaxY=max(YMax_cell);
     464    CoordinatesOut.MinX=min(XMin);
     465    CoordinatesOut.MaxX=max(XMax);
     466    CoordinatesOut.MinY=min(YMin_cell);
     467    CoordinatesOut.MaxY=max(YMax_cell);
    528468end
    529469
     
    719659%%   image or scalar plot %%%%%%%%%%%%%%%%%%%%%%%%%%
    720660
    721 if ~isfield(PlotParam.Scalar,'Contours')
     661if ~isfield(PlotParam.Scalar,'CheckContours')
    722662    PlotParam.Scalar.Contours=0; %default
    723663end
Note: See TracChangeset for help on using the changeset viewer.