Changeset 294
- Timestamp:
- Nov 21, 2011, 5:53:20 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plot_field.m
r292 r294 52 52 % 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. 53 53 % 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 56 58 % .Coordinates.CheckFixEqual: =0 (default):automatic adjustment of the graph, keep 1 to 1 aspect ratio for x and y scales. 57 59 % --scalars-- … … 131 133 end 132 134 end 133 % if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1) 134 % PlotParam=read_plot_param(PlotParam); 135 % end 135 136 136 % create a new figure and axes if the plotting axes does not exist 137 137 if testnewfig … … 176 176 index_0D=find(NbDim==0); 177 177 178 178 %% set axes properties 179 179 if isfield(Coordinates,'CheckFixLimits') && isequal(Coordinates.CheckFixLimits,1) %adjust the graph limits* 180 180 set(haxes,'XLimMode', 'manual') … … 187 187 Coordinates.CheckFixEqual=1; 188 188 end 189 if isfield(Coordinates,'CheckFixEqual') && isequal(Coordinates.CheckFixEqual,1) 189 if isfield(Coordinates,'CheckFixEqual') && isequal(Coordinates.CheckFixEqual,1) 190 190 set(haxes,'DataAspectRatioMode','manual') 191 set(haxes,'DataAspectRatio',[1 1 1])191 set(haxes,'DataAspectRatio',[1 1 1]) 192 192 else 193 193 set(haxes,'DataAspectRatioMode','auto')%automatic aspect ratio … … 222 222 223 223 if isempty(index_1D) 224 224 plot_profile([],[],[],haxes);% 225 225 else 226 Coordinates=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),haxes,PlotParam.Coordinates);%227 228 229 230 231 232 233 234 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'; 235 235 end 236 236 htext=findobj(hfig,'Tag','text_display'); … … 378 378 eval(['data.' VarName '=squeeze(data.' VarName ');']) 379 379 %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))); 382 382 plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot_0 ',']; 383 383 eval(['nbcomponent2=size(data.' VarName ',2);']); … … 453 453 454 454 %% 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)]; 457 fix_lim=isfield(Coordinates,'CheckFixLimits') && Coordinates.CheckFixLimits; 458 458 if fix_lim 459 459 if ~isfield(Coordinates,'MinX')||~isfield(Coordinates,'MaxX')||~isfield(Coordinates,'MinY')||~isfield(Coordinates,'MaxY') … … 461 461 end 462 462 end 463 if ~fix_lim 463 if fix_lim 464 set(haxes,'XLim',[Coordinates.MinX Coordinates.MaxX]) 465 set(haxes,'YLim',[Coordinates.MinY Coordinates.MaxY]) 466 else 464 467 CoordinatesOut.MinX=min(XMin); 465 468 CoordinatesOut.MaxX=max(XMax); … … 550 553 if test_vec 551 554 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)) 553 556 test_black=1; 554 557 end … … 659 662 %% image or scalar plot %%%%%%%%%%%%%%%%%%%%%%%%%% 660 663 661 if ~isfield(PlotParam.Scalar,'CheckContours') 662 PlotParam.Scalar.Contours=0; %default 664 if isfield(PlotParam.Scalar,'ListContour') 665 CheckContour=strcmp(PlotParam.Scalar.ListContour{1},'contours'); 666 else 667 CheckContour=0; %default 663 668 end 664 669 PlotParamOut=PlotParam; %default … … 683 688 684 689 %set the color map 685 if isfield(PlotParam.Scalar,' BW')686 BW=PlotParam.Scalar. BW; %test for BW gray scale images690 if isfield(PlotParam.Scalar,'CheckBW') 691 BW=PlotParam.Scalar.CheckBW; %test for BW gray scale images 687 692 else 688 693 BW=(siz==2) && (isa(A,'uint8')|| isa(A,'uint16'));% non color images represented in gray scale by default … … 691 696 %case of grey level images or contour plot 692 697 if siz==2 693 if ~isfield(PlotParam.Scalar,' FixScal')694 PlotParam.Scalar. FixScal=0;%default698 if ~isfield(PlotParam.Scalar,'CheckFixScalar') 699 PlotParam.Scalar.CheckFixScalar=0;%default 695 700 end 696 701 if ~isfield(PlotParam.Scalar,'MinA') … … 701 706 end 702 707 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 box708 if ~PlotParam.Scalar.CheckFixScalar ||isempty(PlotParam.Scalar.MinA)||~isa(PlotParam.Scalar.MinA,'double') %correct if there is no numerical data in edit box 704 709 Aline=reshape(A,1,[]); 705 710 Aline=Aline(~isnan(A)); … … 709 714 end 710 715 MinA=double(min(Aline)); 711 %MinA=double(min(min(A)));712 716 else 713 717 MinA=PlotParam.Scalar.MinA; 714 718 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 box719 if ~PlotParam.Scalar.CheckFixScalar||isempty(PlotParam.Scalar.MaxA)||~isa(PlotParam.Scalar.MaxA,'double') %correct if there is no numerical data in edit box 716 720 if isempty(Aline) 717 721 Aline=reshape(A,1,[]); … … 723 727 end 724 728 MaxA=double(max(Aline)); 725 % MaxA=double(max(max(A)));726 729 else 727 730 MaxA=PlotParam.Scalar.MaxA; … … 729 732 PlotParamOut.Scalar.MinA=MinA; 730 733 PlotParamOut.Scalar.MaxA=MaxA; 731 732 734 % case of contour plot 733 if isequal(PlotParam.Scalar.Contours,1)735 if CheckContour 734 736 if ~isempty(hima) && ishandle(hima) 735 737 delete(hima) … … 738 740 PlotParam.Scalar.IncrA=NaN; 739 741 end 740 if is nan(PlotParam.Scalar.IncrA)% | PlotParam.Scalar.AutoScal==0742 if isempty(PlotParam.Scalar.IncrA)|| isnan(PlotParam.Scalar.IncrA)% | PlotParam.Scalar.AutoScal==0 741 743 cont=colbartick(MinA,MaxA); 742 744 intercont=cont(2)-cont(1);%default … … 780 782 781 783 % set colormap for image display 782 if ~ isequal(PlotParam.Scalar.Contours,1)784 if ~CheckContour 783 785 % rescale the grey levels with min and max, put a grey scale colorbar 784 786 B=A; … … 804 806 805 807 % display usual image 806 if ~ isequal(PlotParam.Scalar.Contours,1)808 if ~CheckContour 807 809 % interpolate field to increase resolution of image display 808 810 test_interp=1; … … 860 862 %YTick=0;%default 861 863 if MaxA>MinA 862 if isequal(PlotParam.Scalar.Contours,1)864 if CheckContour 863 865 colbarlim=get(hcol,'YLim'); 864 866 scale_bar=(colbarlim(2)-colbarlim(1))/(abscontmax-abscontmin); … … 866 868 YTick_scaled=colbarlim(1)+scale_bar*(YTick-abscontmin); 867 869 set(hcol,'YTick',YTick_scaled); 868 elseif (isfield(PlotParam.Scalar,' BW') && isequal(PlotParam.Scalar.BW,1))||isa(A,'uint8')|| isa(A,'uint16')%images870 elseif (isfield(PlotParam.Scalar,'CheckBW') && isequal(PlotParam.Scalar.CheckBW,1))||isa(A,'uint8')|| isa(A,'uint16')%images 869 871 hi=get(hcol,'children'); 870 872 if iscell(hi)%multiple images in colorbar … … 913 915 vec_V=reshape(vec_V,1,numel(vec_V)); 914 916 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')... 916 918 &&~isempty(PlotParam.Vectors.VecScale) && isa(PlotParam.Vectors.VecScale,'double') %fixed vector scale 917 919 scale=PlotParam.Vectors.VecScale; %impose the length of vector representation … … 941 943 942 944 %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 944 946 diffy=diff(vec_Y); %difference dy=vec_Y(i+1)-vec_Y(i) 945 947 dy_thresh=max(abs(diffy))/2; … … 977 979 col_vec(vec_F~=1 & vec_F~=0 & vec_FF==0)=nbcolor; 978 980 else 979 % ind_flag=find(vec_F~=1 & vec_F~=0);980 981 col_vec(vec_F~=1 & vec_F~=0)=nbcolor; 981 982 end 982 % col_vec(ind_flag)=nbcolor;983 983 end 984 984 nbcolor=nbcolor+1; 985 985 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 988 987 colorlist(nbcolor,:)=[NaN NaN NaN];% no plot of false vectors 989 988 else … … 1015 1014 YMin=[]; 1016 1015 YMax=[]; 1017 fix_lim=isfield(PlotParam,' FixLimits') && PlotParam.FixLimits;1016 fix_lim=isfield(PlotParam,'CheckFixLimits') && PlotParam.CheckFixLimits; 1018 1017 if fix_lim 1019 1018 if ~isfield(PlotParam,'MinX')||~isfield(PlotParam,'MaxX')||~isfield(PlotParam,'MinY')||~isfield(PlotParam,'MaxY')
Note: See TracChangeset
for help on using the changeset viewer.