Changeset 71 for trunk/src/plot_field.m


Ignore:
Timestamp:
Mar 29, 2010, 6:34:55 PM (14 years ago)
Author:
sommeria
Message:

civ3D updated: introduction of image size
imadoc2struct: reding of image size from the xml file
set_object, view_field and related functions: improvement of projection object editing
mouse: possibility of adjusting the calibrations points with the mouse

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plot_field.m

    r61 r71  
    100100
    101101function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,KeepLim,PosColorbar)
     102
    102103%default output
    103104if ~exist('PlotParam','var'),PlotParam=[];end;
     
    151152    haxes=axes;
    152153    set(haxes,'position',[0.13,0.2,0.775,0.73])
     154else
     155    hstack=findobj(allchild(0),'Type','figure');%current stack order of figures in matlab
    153156end
    154157if isfield(PlotParam,'text_display_1')& ishandle(PlotParam.text_display_1)
     
    226229
    227230set(haxes,'UserData',AxeData)
     231if ~testnewfig
     232set(0,'Children',hstack);%put back the initial figure stack after plot creation
    228233%set(haxes,'Tag','uvmat');
    229 
    230  
    231 % %-------------------------------------------
    232 % function [AxeData,haxes]=plot_hist(Data,haxes,PlotParam)% TODO: chech whether this function is still used, replace by plot_profile ?
    233 % %------------------------------------------
    234 % AxeData=get(haxes,'UserData'); %defau
    235 % hfig=get(haxes,'parent');
    236 % if ~isfield(Data,'ListVarName')
    237 %     return
    238 % end
    239 % ColorOrder=[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];
    240 % set(haxes,'ColorOrder',ColorOrder)
    241 % if isfield(PlotParam,'NextPlot')
    242 %     set(haxes,'NextPlot',PlotParam.NextPlot)
    243 % end
    244 % charplot='''-''';
    245 % iplot=0;
    246 % legend_str={};
    247 % label_str='';
    248 % textmean={};
    249 % plotstr='plot(';
    250 % for ilist=1:length(Data.ListVarName)
    251 %     VarName=Data.ListVarName{ilist};
    252 %     eval(['[' VarName 'hist,' VarName 'val]=hist(double(Data.' VarName '),100);']);%coordinate variable set as c
    253 %     plotstr=[plotstr VarName 'val,' VarName 'hist,' charplot ','];
    254 %     eval(['nbcomponent2=size(Data.' VarName ',2);']);
    255 %     eval(['nbcomponent1=size(Data.' VarName ',1);']);
    256 %     eval(['varmean=mean(double(Data.' VarName '));']);%mean value
    257 %     textmean=[textmean; {[VarName 'mean= ' num2str(varmean,4)]}];
    258 %     if nbcomponent1==1| nbcomponent2==1
    259 %         legend_str=[legend_str {VarName}]; %variable with one component
    260 %     else
    261 %         for ic=1:min(nbcomponent1,nbcomponent2)
    262 %             legend_str=[legend_str [VarName '_' num2str(ic)]]; %variable with severals  components
    263 %                                                                % labeled by their index (e.g. color component)
    264 %         end
    265 %     end
    266 %     label_str=[label_str ' ' VarName];
    267 % end
    268 % if ~isequal(plotstr,'plot(')
    269 %     plotstr(end)=')';
    270 %     eval(plotstr)
    271 %     hlegend=findobj(hfig,'Tag','legend');%find existing legend on the plot
    272 %     if ~isempty(hlegend)
    273 %         legend_old=get(hlegend,'String');
    274 %         if isequal(size(legend_old,1),size(legend_str,1))
    275 %              legend_str=[legend_old legend_str];
    276 %         end
    277 %     end
    278 %     legend(legend_str)
    279 %     xlabel(label_str)
    280 %     ylabel('nb values')
    281 %      grid on
    282 %     title_str='';
    283 %     if isfield(Data,'filename')
    284 %        [Path, title_str, ext]=fileparts(Data.filename);
    285 %        title_str=[title_str ext];
    286 %     end
    287 %     if isfield(Data,'Action')
    288 %         if ~isequal(title_str,'')
    289 %             title_str=[title_str ', '];
    290 %         end
    291 %         title_str=[title_str Data.Action];
    292 %     end
    293 %     htitle=title(title_str);
    294 %     set(htitle,'Interpreter','none')% desable tex interpreter
    295 %     hlist=findobj(gcf,'Style','listbox');
    296 %     if isempty(hlist)
    297 %             uicontrol('Style','popupmenu','Position',[20 20 200 20],'String',textmean);
    298 %     else
    299 %             set(hlist(1),'String',textmean)
    300 %     end
    301 % end
    302 % AxeData=Data;
     234end
    303235
    304236
     
    309241hfig=get(haxes,'parent');
    310242AxeData=data;
     243
    311244ColorOrder=[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];
    312245set(haxes,'ColorOrder',ColorOrder)
     
    325258
    326259%initiates string of the plot command
    327 plotstr='plot(';
     260plotstr='hhh=plot(';
    328261textmean={};
    329262abscissa_name='';
    330263coord_x_index=[];
     264test_newplot=1;
    331265for icell=1:length(CellVarIndex)
    332266    testfalse=0;
     
    354288    charplot_0='''-''';%default
    355289    if isfield(data,'ObjectProjMode')& isequal(data.ObjectProjMode,'projection')
    356         charplot_0='''+''';
     290        charplot_0='+';
    357291    end
    358292    xtitle=''; 
     
    372306            testplot(VarType{icell}.warnflag)=0;
    373307    end
    374     if ~isempty(VarType{icell}.discrete')
    375          charplot_0='''+''';
    376     else
    377           charplot_0='''-''';
    378     end
     308 
    379309    if isfield(data,'VarAttribute')
    380310        VarAttribute=data.VarAttribute;
     
    387317        end
    388318    end
    389     for ivar=1:length(VarIndex)
    390         if testplot(VarIndex(ivar))
    391             VarName=data.ListVarName{VarIndex(ivar)};
    392             eval(['data.' VarName '=squeeze(data.' VarName ');'])
    393             if isequal(VarName,'A')
    394                 charplot='''-''';
    395             else
    396                 charplot=charplot_0;
    397             end
    398             plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot ','];
    399             eval(['nbcomponent2=size(data.' VarName ',2);']);
    400             eval(['nbcomponent1=size(data.' VarName ',1);']);
    401             if numel(coord_x{icell})==2
    402                 coord_x{icell}=linspace(coord_x{icell}(1),coord_x{icell}(2),nbcomponent1);
    403             end
    404             eval(['varmean=mean(double(data.' VarName '));']);%mean value
    405             textmean=[textmean; {[VarName 'mean= ' num2str(varmean,4)]}];
    406             if nbcomponent1==1| nbcomponent2==1
    407                 legend_str=[legend_str {VarName}]; %variable with one component
    408             else  %variable with severals  components
    409                 for ic=1:min(nbcomponent1,nbcomponent2)
    410                     legend_str=[legend_str [VarName '_' num2str(ic)]]; %variable with severals  components
    411                 end                                                   % labeled by their index (e.g. color component)
    412             end
    413         end
    414     end
    415 end
    416 if ~isequal(plotstr,'plot(')
    417     plotstr(end)=')';
    418                 %execute plot (instruction  plotstr)   
     319    hh=findobj(haxes,'tag','plot_line');
     320    if isequal(numel(hh),numel(find(testplot(VarIndex))))%update existing curves
     321        icurve=0;
     322        test_newplot=0;
     323        if ~isempty(VarType{icell}.discrete')
     324            charplot_0='+';
     325            LineStyle='none';
     326        else
     327            charplot_0='none';
     328            LineStyle='-';
     329        end
     330        for ivar=1:length(VarIndex)
     331            if testplot(VarIndex(ivar))
     332                icurve=icurve+1;
     333                VarName=data.ListVarName{VarIndex(ivar)};
     334                eval(['data.' VarName '=squeeze(data.' VarName ');'])
     335                set(hh(icurve),'LineStyle',LineStyle)
     336                set(hh(icurve),'Marker',charplot_0)
     337%                 if isequal(VarName,'A')
     338%                     set(hh(icurve),'LineStyle','-');
     339%                 else
     340%                     set(hh(icurve),'LineStyle',charplot_0);
     341%                 end
     342                set(hh(icurve),'XData',coord_x{icell})
     343                eval(['yy=data.' VarName ';'])
     344                set(hh(icurve),'YData',yy);
     345%                 eval(['nbcomponent2=size(data.' VarName ',2);']);
     346%                 eval(['nbcomponent1=size(data.' VarName ',1);']);
     347%                 if numel(coord_x{icell})==2
     348%                     coord_x{icell}=linspace(coord_x{icell}(1),coord_x{icell}(2),nbcomponent1);
     349%                 end
     350%                 eval(['varmean=mean(double(data.' VarName '));']);%mean value
     351%                 textmean=[textmean; {[VarName 'mean= ' num2str(varmean,4)]}];
     352%                 if nbcomponent1==1| nbcomponent2==1
     353%                     legend_str=[legend_str {VarName}]; %variable with one component
     354%                 else  %variable with severals  components
     355%                     for ic=1:min(nbcomponent1,nbcomponent2)
     356%                         legend_str=[legend_str [VarName '_' num2str(ic)]]; %variable with severals  components
     357%                     end                                                   % labeled by their index (e.g. color component)
     358%                 end
     359            end
     360        end
     361    else% new plot
     362        if ~isempty(VarType{icell}.discrete')
     363            charplot_0='''+''';
     364        else
     365            charplot_0='''-''';
     366        end
     367        for ivar=1:length(VarIndex)
     368            if testplot(VarIndex(ivar))
     369                VarName=data.ListVarName{VarIndex(ivar)};
     370                eval(['data.' VarName '=squeeze(data.' VarName ');'])
     371%                 if isequal(VarName,'A')
     372%                     charplot='''-''';
     373%                 else
     374%                     charplot=charplot_0;
     375%                 end
     376                plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot_0 ','];
     377                eval(['nbcomponent2=size(data.' VarName ',2);']);
     378                eval(['nbcomponent1=size(data.' VarName ',1);']);
     379                if numel(coord_x{icell})==2
     380                    coord_x{icell}=linspace(coord_x{icell}(1),coord_x{icell}(2),nbcomponent1);
     381                end
     382                eval(['varmean=mean(double(data.' VarName '));']);%mean value
     383                textmean=[textmean; {[VarName 'mean= ' num2str(varmean,4)]}];
     384                if nbcomponent1==1| nbcomponent2==1
     385                    legend_str=[legend_str {VarName}]; %variable with one component
     386                else  %variable with severals  components
     387                    for ic=1:min(nbcomponent1,nbcomponent2)
     388                        legend_str=[legend_str [VarName '_' num2str(ic)]]; %variable with severals  components
     389                    end                                                   % labeled by their index (e.g. color component)
     390                end
     391            end
     392        end
     393    end
     394end
     395if test_newplot && ~isequal(plotstr,'plot(')
     396    plotstr=[plotstr '''tag'',''plot_line'')']
     397                %execute plot (instruction  plotstr) 
    419398    eval(plotstr)
     399   
    420400                %%%%%
    421     grid on
     401    grid(haxes, 'on')
    422402    hxlabel=xlabel(xtitle);
    423403    set(hxlabel,'Interpreter','none')% desable tex interpreter
     
    478458%----------------------------------------
    479459function [AxeData,haxes,PlotParamOut,PlotType]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,KeepLim,PosColorbar)
    480 
     460grid(haxes, 'off')
    481461%default plotting parameters
    482462PlotType='plane';%default
Note: See TracChangeset for help on using the changeset viewer.