Changeset 192 for trunk/src/plot_field.m


Ignore:
Timestamp:
Feb 14, 2011, 7:03:10 PM (13 years ago)
Author:
sommeria
Message:

civ: version working for all systems: windows, linux, mac
plots: introduction of axes limits , bug repairs (still further work needed)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plot_field.m

    r191 r192  
    128128    end
    129129end
    130 if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1)
    131     PlotParam=read_plot_param(PlotParam);   
    132 end
     130% if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1)
     131%     PlotParam=read_plot_param(PlotParam);   
     132% end
    133133% create a new figure and axes if the plotting axes does not exist
    134134if testnewfig
    135135    hfig=figure;
    136     if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1)
    137         set(hfig,'UserData',PlotParam)
    138     end
     136%     if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1)
     137%         set(hfig,'UserData',PlotParam)
     138%     end
    139139    set(hfig,'Units','normalized')
    140     set(hfig,'WindowButtonDownFcn','mouse_down')
    141     set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action function
    142     set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse action function
     140%     set(hfig,'WindowButtonDownFcn','mouse_down')
     141%     set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action function
     142%     set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse action function
    143143    haxes=axes;
    144144    set(haxes,'position',[0.13,0.2,0.775,0.73])
     
    146146else
    147147    hfig=get(haxes,'parent');
    148     set(0,'CurrentFigure',hfig)
    149     set(hfig,'CurrentAxes',haxes)
     148    set(0,'CurrentFigure',hfig)% the parent of haxes becomes the current figure
     149    set(hfig,'CurrentAxes',haxes)%  haxes becomes the current axes of the parent figure
    150150end
    151151
     
    153153if ~isempty(Data)
    154154    [Data,errormsg]=check_field_structure(Data);
    155 
    156155    if ~isempty(errormsg)
    157156        msgbox_uvmat('ERROR',['input of plot_field/check_field_structure: ' errormsg])
     
    213212        PlotType='line';
    214213end
     214
    215215if isempty(index_2D)
    216216    plot_plane([],[],[],haxes);%removes images or vector plots if any
     
    330330function PlotParamOut=plot_profile(data,CellVarIndex,VarType,haxes,PlotParam)
    331331%-------------------------------------------------------------------
     332if ~exist('PlotParam','var')
     333    PlotParam=[];
     334end
    332335PlotParamOut=PlotParam; %default
    333336hfig=get(haxes,'parent');
     
    10301033
    10311034%store the coordinate extrema occupied by the field
     1035Data
    10321036if ~isempty(Data)
    1033     test_lim=0;
    1034     if test_vec
    1035         Xlim=[min(vec_X) max(vec_X)];
    1036         Ylim=[min(vec_Y) max(vec_Y)];
    1037         test_lim=1;
     1037    fix_lim=isfield(PlotParam,'FixLimits') && PlotParam.FixLimits;
     1038    if fix_lim
     1039        if ~isfield(PlotParam,'MinX')||~isfield(PlotParam,'MaxX')||~isfield(PlotParam,'MinY')||~isfield(PlotParam,'MaxY')
     1040            fix_lim=0; %free limits if lits are not set,
     1041        end  %else PlotParamOut.XMin =PlotParam.XMin...
     1042    end
     1043    'TESTfix'
     1044    fix_lim
     1045    if ~fix_lim
     1046        XMin=[];
     1047        XMax=[];
     1048        YMin=[];
     1049        YMax=[];
    10381050        if test_ima%both background image and vectors coexist, take the wider bound
    1039             Xlim(1)=min(AX(1),Xlim(1));
    1040             Xlim(2)=max(AX(end),Xlim(2));
    1041             Ylim(1)=min(AY(end),Ylim(1));
    1042             Ylim(2)=max(AY(1),Ylim(2));
    1043         end
    1044     elseif test_ima %only image plot
    1045         Xlim(1)=min(AX(1),AX(end));
    1046         Xlim(2)=max(AX(1),AX(end));
    1047         Ylim(1)=min(AY(1),AY(end));
    1048         Ylim(2)=max(AY(1),AY(end));
    1049         test_lim=1;
    1050     end
    1051     AxeData.RangeX=Xlim;
    1052     AxeData.RangeY=Ylim;
    1053 
    1054 %    adjust the size of the plot to include the whole field, except if PlotParam.FixedLimits=1
    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 
    1068     set(haxes,'YDir','normal')
     1051            XMin=min(AX);
     1052            XMax=max(AX);
     1053            YMin=min(AY);
     1054            YMax=max(AY);
     1055        end
     1056        if test_vec
     1057            XMin=[XMin min(vec_X)];
     1058            XMax=[XMax max(vec_X)];
     1059            YMin=[YMin min(vec_Y)];
     1060            YMax=[YMax max(vec_Y)];
     1061        end
     1062        PlotParamOut.MinX=min(XMin);
     1063        PlotParamOut.MaxX=max(XMax);
     1064        PlotParamOut.MinY=min(YMin);
     1065        PlotParamOut.MaxY=max(YMax);
     1066        if XMax>XMin
     1067            set(haxes,'XLim',[XMin XMax]);% set x limits of frame in axes coordinates
     1068        end
     1069        if YMax>YMin
     1070            set(haxes,'YLim',[YMin YMax]);% set x limits of frame in axes coordinates
     1071        end
     1072    end
     1073%     if Ylim(2)>Ylim(1)
     1074%         set(haxes,'YLim',Ylim);% set y limits of frame in axes coordinate
     1075%     end
     1076%     end
     1077    %    adjust the size of the plot to include the whole field, except if PlotParam.FixLimits=1
     1078    %     if ~(isfield(PlotParam,'FixLimits') && PlotParam.FixLimits) && test_lim
     1079    %         PlotParamOut.MinX=Xlim(1);
     1080    %         PlotParamOut.MaxX=Xlim(2);
     1081    %         PlotParamOut.MinY=Ylim(1);
     1082    %         PlotParamOut.MaxY=Ylim(2);
     1083%     if Xlim(2)>Xlim(1)
     1084%         set(haxes,'XLim',Xlim);% set x limits of frame in axes coordinates
     1085%     end
     1086%     if Ylim(2)>Ylim(1)
     1087%         set(haxes,'YLim',Ylim);% set y limits of frame in axes coordinate
     1088%     end
     1089    %     end
     1090
     1091    set(haxes,'YDir','normal')
    10691092    set(get(haxes,'XLabel'),'String',[XName ' (' x_units ')']);
    10701093    set(get(haxes,'YLabel'),'String',[YName ' (' y_units ')']);
Note: See TracChangeset for help on using the changeset viewer.