Changeset 191 for trunk/src/plot_field.m


Ignore:
Timestamp:
Feb 5, 2011, 11:25:38 PM (13 years ago)
Author:
sommeria
Message:

introduce edit boxes to set axis limits. rationalisation of names FixScal?, FixLimits?....
introduce volume scan in calibration procedures

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plot_field.m

    r188 r191  
    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
     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.
    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.AutoScal: =1 (default) lower and upper bounds of the scalar representation set to the min and max of the field
    61 %               =0 lower and upper bound imposed by .AMax and .MinA
     60%    .Scalar.FixScal: =0 (default) lower and upper bounds of the scalar representation set to the min and max of the field
     61%               =1 lower and upper bound imposed by .AMax and .MinA
    6262%    .Scalar.BW= 1 black and white representation imposed, =0 by default.
    6363%    .Scalar.Contours= 1: represent scalars by contour plots (Matlab function 'contour'); =0 by default
     
    6565%            -- vectors--
    6666%    .Vectors.VecScale: scale for the vector representation
    67 %    .Vectors.AutoVec: =0 (default) automatic length for vector representation, =1: length set by .VecScale
     67%    .Vectors.FixVec: =0 (default) automatic length for vector representation, =1: length set by .VecScale
    6868%    .Vectors.HideFalse= 0 (default) false vectors represented in magenta, =1: false vectors not represented;
    6969%    .Vectors.HideWarning= 0 (default) vectors marked by warnflag~=0 marked in black, 1: no warning representation;
     
    177177   
    178178        %% set axes properties
    179     if isfield(PlotParam,'FixedLimits') && isequal(PlotParam.FixedLimits,1)  %adjust the graph limits*
     179    if isfield(PlotParam,'FixLimits') && isequal(PlotParam.FixLimits,1)  %adjust the graph limits*
    180180        set(haxes,'XLimMode', 'manual')
    181181        set(haxes,'YLimMode', 'manual')
     
    184184        set(haxes,'YLimMode', 'auto')
    185185    end
    186     if isfield(PlotParam,'Auto_xy') && isequal(PlotParam.Auto_xy,1)
     186    if ~isfield(PlotParam,'FixEqual')&& isfield(Data,'CoordUnit')
     187        PlotParam.FixEqual=1;
     188    end
     189    if isfield(PlotParam,'FixEqual') && isequal(PlotParam.FixEqual,1)
     190        set(haxes,'DataAspectRatioMode','manual')
     191       set(haxes,'DataAspectRatio',[1 1 1])
     192    else
    187193        set(haxes,'DataAspectRatioMode','auto')%automatic aspect ratio
    188     else
    189         set(haxes,'DataAspectRatioMode','manual')
    190194    end
    191195else
     
    199203errormsg=[];
    200204AxeData=get(haxes,'UserData');
     205if isempty(index_1D)
     206     plot_profile([],[],[],haxes);%
     207else
     208        PlotParamOut=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),haxes,PlotParam);%
     209        if testzoomaxes
     210            [zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),zoomaxes,PlotParam);
     211            AxeData.ZoomAxes=zoomaxes;
     212        end
     213        PlotType='line';
     214end
    201215if isempty(index_2D)
    202216    plot_plane([],[],[],haxes);%removes images or vector plots if any
     
    209223            end
    210224end
    211 if isempty(index_1D)
    212      plot_profile([],[],[],haxes);%
    213 else
    214         plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),haxes,PlotParam);%
    215         if testzoomaxes
    216             [zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),zoomaxes,PlotParam);
    217             AxeData.ZoomAxes=zoomaxes;
    218         end
    219         PlotType='line';
    220 end
    221225htext=findobj(hfig,'Tag','text_display');
    222226if ~isempty(htext)
     
    230234if ~isempty(errormsg)
    231235    msgbox_uvmat('ERROR', errormsg)
     236end
     237if isfield(PlotParamOut,'MinX')
     238set(haxes,'XLim',[PlotParamOut.MinX PlotParamOut.MaxX])
     239set(haxes,'YLim',[PlotParamOut.MinY PlotParamOut.MaxY])
    232240end
    233241
     
    320328
    321329%-------------------------------------------------------------------
    322 function [haxes]=plot_profile(data,CellVarIndex,VarType,haxes,PlotParam)
     330function PlotParamOut=plot_profile(data,CellVarIndex,VarType,haxes,PlotParam)
    323331%-------------------------------------------------------------------
     332PlotParamOut=PlotParam; %default
    324333hfig=get(haxes,'parent');
    325334%suppress existing plot isf empty data
     
    504513    PlotParam.Vectors=[];
    505514end
     515
    506516PlotParamOut=PlotParam;%default
    507517hfig=get(haxes,'parent');
    508518hcol=findobj(hfig,'Tag','Colorbar'); %look for colorbar axes
    509519hima=findobj(haxes,'Tag','ima');% search existing image in the current axes
    510 % AxeData=get(haxes,'UserData'); %default
    511 % if ~isstruct(AxeData)% AxeData must be a structure
    512 %     AxeData=[];
    513 % end
    514 % AxeData.NbDim=2;
    515 % if isfield(Data,'ObjectCoord')
    516 %     AxeData.ObjectCoord=Data.ObjectCoord;
    517 % end
    518520errormsg=[];%default
    519521test_ima=0; %default: test for image or map plot
     
    720722    %case of grey level images or contour plot
    721723    if siz==2
    722         if ~isfield(PlotParam.Scalar,'AutoScal')
    723             PlotParam.Scalar.AutoScal=0;%default
     724        if ~isfield(PlotParam.Scalar,'FixScal')
     725            PlotParam.Scalar.FixScal=0;%default
    724726        end
    725727        if ~isfield(PlotParam.Scalar,'MinA')
     
    729731            PlotParam.Scalar.MaxA=[];%default
    730732        end
    731         if isequal(PlotParam.Scalar.AutoScal,0)||isempty(PlotParam.Scalar.MinA)||~isa(PlotParam.Scalar.MinA,'double')  %correct if there is no numerical data in edit box
     733        if isequal(PlotParam.Scalar.FixScal,0)||isempty(PlotParam.Scalar.MinA)||~isa(PlotParam.Scalar.MinA,'double')  %correct if there is no numerical data in edit box
    732734            MinA=double(min(min(A)));
    733735        else
    734736            MinA=PlotParam.Scalar.MinA; 
    735737        end;
    736         if isequal(PlotParam.Scalar.AutoScal,0)||isempty(PlotParam.Scalar.MaxA)||~isa(PlotParam.Scalar.MaxA,'double') %correct if there is no numerical data in edit box
     738        if isequal(PlotParam.Scalar.FixScal,0)||isempty(PlotParam.Scalar.MaxA)||~isa(PlotParam.Scalar.MaxA,'double') %correct if there is no numerical data in edit box
    737739            MaxA=double(max(max(A)));
    738740        else
     
    10491051    AxeData.RangeX=Xlim;
    10501052    AxeData.RangeY=Ylim;
     1053
    10511054%    adjust the size of the plot to include the whole field, except if PlotParam.FixedLimits=1
    1052     if ~(isfield(PlotParam,'FixedLimits') && PlotParam.FixedLimits) && test_lim
    1053             if Xlim(2)>Xlim(1)
    1054                 set(haxes,'XLim',Xlim);% set x limits of frame in axes coordinates
    1055             end
    1056             if Ylim(2)>Ylim(1)
    1057                 set(haxes,'YLim',Ylim);% set y limits of frame in axes coordinate
    1058             end
    1059     end
    1060     if ~(isfield(PlotParam,'Auto_xy') && isequal(PlotParam.Auto_xy,1))
    1061          set(haxes,'DataAspectRatio',[1 1 1])
    1062     end
     1055    if ~(isfield(PlotParam,'FixLimits') && PlotParam.FixLimits) && test_lim
     1056        PlotParamOut.MinX=Xlim(1);
     1057        PlotParamOut.MaxX=Xlim(2);
     1058        PlotParamOut.MinY=Ylim(1);
     1059        PlotParamOut.MaxY=Ylim(2);
     1060        if Xlim(2)>Xlim(1)
     1061            set(haxes,'XLim',Xlim);% set x limits of frame in axes coordinates
     1062        end
     1063        if Ylim(2)>Ylim(1)
     1064            set(haxes,'YLim',Ylim);% set y limits of frame in axes coordinate
     1065        end
     1066    end
     1067
    10631068    set(haxes,'YDir','normal')
    10641069    set(get(haxes,'XLabel'),'String',[XName ' (' x_units ')']);
Note: See TracChangeset for help on using the changeset viewer.