Changeset 294


Ignore:
Timestamp:
Nov 21, 2011, 5:53:20 PM (9 years ago)
Author:
sommeria
Message:

plotting functions debugged and checked after the introduction of uipanels

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plot_field.m

    r292 r294  
    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 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
     54%   PlotParam: structure containing the parameters for plotting, as read on the uvmat or view_field GUI (by function 'read_GUI.m').
     55%      Contains three substructures:
     56%     .Coordinates: coordinate parameters:
     57%           .CheckFixLimits:=0 (default) adjust axes limit to the X,Y data, =1: preserves the previous axes limits
    5658%     .Coordinates.CheckFixEqual: =0 (default):automatic adjustment of the graph, keep 1 to 1 aspect ratio for x and y scales.
    5759%            --scalars--
     
    131133    end
    132134end
    133 % if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1)
    134 %     PlotParam=read_plot_param(PlotParam);   
    135 % end
     135
    136136% create a new figure and axes if the plotting axes does not exist
    137137if testnewfig
     
    176176    index_0D=find(NbDim==0);
    177177   
    178         %% set axes properties
     178    %% set axes properties
    179179    if isfield(Coordinates,'CheckFixLimits') && isequal(Coordinates.CheckFixLimits,1)  %adjust the graph limits*
    180180        set(haxes,'XLimMode', 'manual')
     
    187187        Coordinates.CheckFixEqual=1;
    188188    end
    189     if isfield(Coordinates,'CheckFixEqual') && isequal(Coordinates.CheckFixEqual,1) 
     189    if isfield(Coordinates,'CheckFixEqual') && isequal(Coordinates.CheckFixEqual,1)
    190190        set(haxes,'DataAspectRatioMode','manual')
    191        set(haxes,'DataAspectRatio',[1 1 1])
     191        set(haxes,'DataAspectRatio',[1 1 1])
    192192    else
    193193        set(haxes,'DataAspectRatioMode','auto')%automatic aspect ratio
     
    222222
    223223if isempty(index_1D)
    224      plot_profile([],[],[],haxes);%
     224    plot_profile([],[],[],haxes);%
    225225else
    226         Coordinates=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),haxes,PlotParam.Coordinates);%
    227         if testzoomaxes
    228             [zoomaxes,Coordinates]=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),zoomaxes,PlotParam.Coordinates);
    229             AxeData.ZoomAxes=zoomaxes;
    230         end
    231         if ~isempty(Coordinates)
    232             PlotParamOut.Coordinates=Coordinates;
    233         end
    234         PlotType='line';
     226    Coordinates=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),haxes,Coordinates);%
     227    if testzoomaxes
     228        [zoomaxes,Coordinates]=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),zoomaxes,PlotParam.Coordinates);
     229        AxeData.ZoomAxes=zoomaxes;
     230    end
     231    if ~isempty(Coordinates)
     232        PlotParamOut.Coordinates=Coordinates;
     233    end
     234    PlotType='line';
    235235end
    236236htext=findobj(hfig,'Tag','text_display');
     
    378378            eval(['data.' VarName '=squeeze(data.' VarName ');'])
    379379            %eval(['min(data.' VarName ')'])
    380             eval(['YMin(ivar)=min(min(data.' VarName '));'])
    381             eval(['YMax(ivar)=max(max(data.' VarName '));'])
     380            YMin(ivar)=min(min(data.(VarName)));
     381            YMax(ivar)=max(max(data.(VarName)));
    382382            plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot_0 ','];
    383383            eval(['nbcomponent2=size(data.' VarName ',2);']);
     
    453453
    454454%% determine axes bounds
    455 CoordinatesOut.RangeX=[min(XMin) max(XMax)];
    456 CoordinatesOut.RangeY=[min(YMin_cell) max(YMax_cell)];
    457 fix_lim=isfield(Coordinates,'FixLimits') && Coordinates.FixLimits;
     455%CoordinatesOut.RangeX=[min(XMin) max(XMax)];
     456%CoordinatesOut.RangeY=[min(YMin_cell) max(YMax_cell)];
     457fix_lim=isfield(Coordinates,'CheckFixLimits') && Coordinates.CheckFixLimits;
    458458if fix_lim
    459459    if ~isfield(Coordinates,'MinX')||~isfield(Coordinates,'MaxX')||~isfield(Coordinates,'MinY')||~isfield(Coordinates,'MaxY')
     
    461461    end
    462462end
    463 if ~fix_lim
     463if fix_lim
     464    set(haxes,'XLim',[Coordinates.MinX Coordinates.MaxX])
     465    set(haxes,'YLim',[Coordinates.MinY Coordinates.MaxY])
     466else   
    464467    CoordinatesOut.MinX=min(XMin);
    465468    CoordinatesOut.MaxX=max(XMax);
     
    550553                if test_vec
    551554                    eval(['vec_F=Data.' Data.ListVarName{ivar_F} ';']) % warning flags for  dubious vectors
    552                     if  ~(isfield(PlotParam.Vectors,'HideWarning') && isequal(PlotParam.Vectors.HideWarning,1))
     555                    if  ~(isfield(PlotParam.Vectors,'CheckHideWarning') && isequal(PlotParam.Vectors.CheckHideWarning,1))
    553556                        test_black=1;
    554557                    end
     
    659662%%   image or scalar plot %%%%%%%%%%%%%%%%%%%%%%%%%%
    660663
    661 if ~isfield(PlotParam.Scalar,'CheckContours')
    662     PlotParam.Scalar.Contours=0; %default
     664if isfield(PlotParam.Scalar,'ListContour')
     665    CheckContour=strcmp(PlotParam.Scalar.ListContour{1},'contours');
     666else
     667    CheckContour=0; %default
    663668end
    664669PlotParamOut=PlotParam; %default
     
    683688   
    684689    %set the color map
    685     if isfield(PlotParam.Scalar,'BW')
    686         BW=PlotParam.Scalar.BW; %test for BW gray scale images
     690    if isfield(PlotParam.Scalar,'CheckBW')
     691        BW=PlotParam.Scalar.CheckBW; %test for BW gray scale images
    687692    else
    688693        BW=(siz==2) && (isa(A,'uint8')|| isa(A,'uint16'));% non color images represented in gray scale by default
     
    691696    %case of grey level images or contour plot
    692697    if siz==2
    693         if ~isfield(PlotParam.Scalar,'FixScal')
    694             PlotParam.Scalar.FixScal=0;%default
     698        if ~isfield(PlotParam.Scalar,'CheckFixScalar')
     699            PlotParam.Scalar.CheckFixScalar=0;%default
    695700        end
    696701        if ~isfield(PlotParam.Scalar,'MinA')
     
    701706        end
    702707        Aline=[];
    703         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
     708        if ~PlotParam.Scalar.CheckFixScalar ||isempty(PlotParam.Scalar.MinA)||~isa(PlotParam.Scalar.MinA,'double')  %correct if there is no numerical data in edit box
    704709            Aline=reshape(A,1,[]);
    705710            Aline=Aline(~isnan(A));
     
    709714            end
    710715            MinA=double(min(Aline));
    711             %MinA=double(min(min(A)));
    712716        else
    713717            MinA=PlotParam.Scalar.MinA;
    714718        end;
    715         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
     719        if ~PlotParam.Scalar.CheckFixScalar||isempty(PlotParam.Scalar.MaxA)||~isa(PlotParam.Scalar.MaxA,'double') %correct if there is no numerical data in edit box
    716720            if isempty(Aline)
    717721               Aline=reshape(A,1,[]);
     
    723727            end
    724728            MaxA=double(max(Aline));
    725            % MaxA=double(max(max(A)));
    726729        else
    727730            MaxA=PlotParam.Scalar.MaxA; 
     
    729732        PlotParamOut.Scalar.MinA=MinA;
    730733        PlotParamOut.Scalar.MaxA=MaxA;
    731        
    732734        % case of contour plot
    733         if isequal(PlotParam.Scalar.Contours,1)
     735        if CheckContour
    734736            if ~isempty(hima) && ishandle(hima)
    735737                delete(hima)
     
    738740                PlotParam.Scalar.IncrA=NaN;
    739741            end
    740             if isnan(PlotParam.Scalar.IncrA)% | PlotParam.Scalar.AutoScal==0
     742            if isempty(PlotParam.Scalar.IncrA)|| isnan(PlotParam.Scalar.IncrA)% | PlotParam.Scalar.AutoScal==0
    741743                cont=colbartick(MinA,MaxA);
    742744                intercont=cont(2)-cont(1);%default
     
    780782       
    781783        % set  colormap for  image display
    782         if ~isequal(PlotParam.Scalar.Contours,1) 
     784        if ~CheckContour
    783785            % rescale the grey levels with min and max, put a grey scale colorbar
    784786            B=A;
     
    804806   
    805807    % display usual image
    806     if ~isequal(PlotParam.Scalar.Contours,1)     
     808    if ~CheckContour     
    807809        % interpolate field to increase resolution of image display
    808810        test_interp=1;
     
    860862        %YTick=0;%default
    861863        if MaxA>MinA
    862             if isequal(PlotParam.Scalar.Contours,1)
     864            if CheckContour
    863865                colbarlim=get(hcol,'YLim');
    864866                scale_bar=(colbarlim(2)-colbarlim(1))/(abscontmax-abscontmin);               
     
    866868                YTick_scaled=colbarlim(1)+scale_bar*(YTick-abscontmin);
    867869                set(hcol,'YTick',YTick_scaled);
    868             elseif (isfield(PlotParam.Scalar,'BW') && isequal(PlotParam.Scalar.BW,1))||isa(A,'uint8')|| isa(A,'uint16')%images
     870            elseif (isfield(PlotParam.Scalar,'CheckBW') && isequal(PlotParam.Scalar.CheckBW,1))||isa(A,'uint8')|| isa(A,'uint16')%images
    869871                hi=get(hcol,'children');
    870872                if iscell(hi)%multiple images in colorbar
     
    913915    vec_V=reshape(vec_V,1,numel(vec_V));
    914916     MinMaxX=max(vec_X)-min(vec_X);
    915     if  isfield(PlotParam.Vectors,'FixVec') && isequal(PlotParam.Vectors.FixVec,1)&& isfield(PlotParam.Vectors,'VecScale')...
     917    if  isfield(PlotParam.Vectors,'CheckFixVectors') && isequal(PlotParam.Vectors.CheckFixVectors,1)&& isfield(PlotParam.Vectors,'VecScale')...
    916918               &&~isempty(PlotParam.Vectors.VecScale) && isa(PlotParam.Vectors.VecScale,'double') %fixed vector scale
    917919        scale=PlotParam.Vectors.VecScale;  %impose the length of vector representation
     
    941943   
    942944    %decimate by a factor 2 in vector mesh(4 in nbre of vectors)
    943     if isfield(PlotParam.Vectors,'decimate4') && isequal(PlotParam.Vectors.decimate4,1)
     945    if isfield(PlotParam.Vectors,'CheckDecimate4') && PlotParam.Vectors.CheckDecimate4
    944946        diffy=diff(vec_Y); %difference dy=vec_Y(i+1)-vec_Y(i)
    945947        dy_thresh=max(abs(diffy))/2;
     
    977979            col_vec(vec_F~=1 & vec_F~=0 & vec_FF==0)=nbcolor;
    978980       else
    979            % ind_flag=find(vec_F~=1 & vec_F~=0);
    980981            col_vec(vec_F~=1 & vec_F~=0)=nbcolor;
    981982       end
    982       % col_vec(ind_flag)=nbcolor;   
    983983    end
    984984    nbcolor=nbcolor+1;
    985985    if ~isempty(ivar_FF)
    986         %ind_flag=find(vec_FF~=0);
    987         if isfield(PlotParam.Vectors,'HideFalse') && PlotParam.Vectors.HideFalse==1
     986        if isfield(PlotParam.Vectors,'CheckHideFalse') && PlotParam.Vectors.CheckHideFalse==1
    988987            colorlist(nbcolor,:)=[NaN NaN NaN];% no plot of false vectors
    989988        else
     
    10151014    YMin=[];
    10161015    YMax=[];
    1017     fix_lim=isfield(PlotParam,'FixLimits') && PlotParam.FixLimits;
     1016    fix_lim=isfield(PlotParam,'CheckFixLimits') && PlotParam.CheckFixLimits;
    10181017    if fix_lim
    10191018        if ~isfield(PlotParam,'MinX')||~isfield(PlotParam,'MaxX')||~isfield(PlotParam,'MinY')||~isfield(PlotParam,'MaxY')
Note: See TracChangeset for help on using the changeset viewer.