Changeset 546 for trunk/src/plot_field.m
- Timestamp:
- Sep 17, 2012, 10:47:38 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plot_field.m
r537 r546 76 76 % .Vectors.MaxC = imposed maximum of the scalar field used for vector color; 77 77 % 78 % PosColorbar: if not empty, display a colorbar for B&W images 79 % imposed position of the colorbar (ex [0.821 0.471 0.019 0.445]) 78 % PosColorbar: % if absent, no action on colorbar 79 % % if empty, suppress any existing colorbar 80 % % if not empty, display a colorbar for B&W images at position PosColorbar 81 % expressed in figure relative unit (ex [0.821 0.471 0.019 0.445]) 80 82 81 83 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA … … 99 101 %% default input and output 100 102 if ~exist('PlotParam','var'),PlotParam=[];end; 101 if ~exist('PosColorbar','var'),PosColorbar=[];end;102 103 PlotType='text'; %default 103 104 PlotParamOut=PlotParam;%default … … 110 111 index_1D=[]; 111 112 index_0D=[]; 112 % errormsg=check_field_structure(Data);113 % if ~isempty(errormsg)114 % msgbox_uvmat('ERROR',['input of plot_field/check_field_structure: ' errormsg])115 % display(['input of plot_field/check_field_structure: ' errormsg])116 % return117 % end118 113 % check the cells of fields : 119 114 [CellInfo,NbDimArray,errormsg]=find_field_cells(Data); … … 126 121 index_3D=find(NbDimArray>2,1); 127 122 if ~isempty(index_3D) 128 % if isfield(Data,'NbDimArray')&& isequal(Data.NbDimArray,2) 129 % index_2D=[index_2D index_3D]; 130 % else 131 msgbox_uvmat('ERROR','volume plot not implemented yet'); 132 return 133 % end 123 msgbox_uvmat('ERROR','volume plot not implemented yet'); 124 return 134 125 end 135 126 index_2D=find(NbDimArray==2);%find 2D fields 136 127 index_1D=find(NbDimArray==1); 137 128 index_0D=find(NbDimArray==0); 138 %remove coordinates variables from 1D plot139 % if ~isempty(index_2D)140 % for ivar=1:length(index_1D)141 % if isequal(CellVarIndex{index_1D(ivar)},VarRole{index_1D(ivar)}.coord)142 % index_1D(ivar)=0;143 % end144 % end145 % index_1D=index_1D(index_1D>0);146 % end147 129 148 130 %% test axes and figure … … 194 176 %% 2D plots 195 177 if isempty(index_2D) 196 plot_plane([],[],haxes );%removes images or vector plots in the absence of 2D field plot178 plot_plane([],[],haxes,[],[]);%removes images or vector plots in the absence of 2D field plot 197 179 else %plot 2D field 180 if ~exist('PosColorbar','var'),PosColorbar=[];end; 198 181 [tild,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo(index_2D),haxes,PlotParam,PosColorbar); 199 182 AxeData.NbDim=2; … … 539 522 %default plotting parameters 540 523 PlotType='plane';%default 541 if ~exist('PlotParam','var')542 PlotParam=[];543 end524 % if ~exist('PlotParam','var') 525 % PlotParam=[]; 526 % end 544 527 545 528 if ~isfield(PlotParam,'Scalar') … … 936 919 set(hima,'YData',AY); 937 920 end 938 921 939 922 % set the transparency to 0.5 if vectors are also plotted 940 923 if isfield(PlotParam.Scalar,'Opacity')&& ~isempty(PlotParam.Scalar.Opacity) … … 952 935 953 936 %display the colorbar code for B/W images if Poscolorbar not empty 954 if siz==2 && exist('PosColorbar','var')&& ~isempty(PosColorbar) 955 if isempty(hcol)||~ishandle(hcol) 956 hcol=colorbar;%create new colorbar 957 end 958 if length(PosColorbar)==4 959 set(hcol,'Position',PosColorbar) 960 end 961 %YTick=0;%default 962 if MaxA>MinA 963 if CheckContour 964 colbarlim=get(hcol,'YLim'); 965 scale_bar=(colbarlim(2)-colbarlim(1))/(abscontmax-abscontmin); 966 YTick=cont_pos(2:end-1); 967 YTick_scaled=colbarlim(1)+scale_bar*(YTick-abscontmin); 968 set(hcol,'YTick',YTick_scaled); 969 elseif (isfield(PlotParam.Scalar,'CheckBW') && isequal(PlotParam.Scalar.CheckBW,1))||isa(A,'uint8')|| isa(A,'uint16')%images 970 hi=get(hcol,'children'); 971 if iscell(hi)%multiple images in colorbar 972 hi=hi{1}; 973 end 974 set(hi,'YData',[MinA MaxA]) 975 set(hi,'CData',(1:256)') 976 set(hcol,'YLim',[MinA MaxA]) 977 YTick=colbartick(MinA,MaxA); 978 set(hcol,'YTick',YTick) 979 else 980 hi=get(hcol,'children'); 981 if iscell(hi)%multiple images in colorbar 982 hi=hi{1}; 983 end 984 set(hi,'YData',[MinA MaxA]) 985 set(hi,'CData',(1:64)') 986 YTick=colbartick(MinA,MaxA); 987 set(hcol,'YLim',[MinA MaxA]) 988 set(hcol,'YTick',YTick) 989 end 990 set(hcol,'Yticklabel',num2str(YTick')); 991 end 992 elseif ishandle(hcol) 993 delete(hcol); %erase existing colorbar if not needed 937 if ~isempty(PosColorbar) 938 if siz==2 && exist('PosColorbar','var') 939 if isempty(hcol)||~ishandle(hcol) 940 hcol=colorbar;%create new colorbar 941 end 942 if length(PosColorbar)==4 943 set(hcol,'Position',PosColorbar) 944 end 945 %YTick=0;%default 946 if MaxA>MinA 947 if CheckContour 948 colbarlim=get(hcol,'YLim'); 949 scale_bar=(colbarlim(2)-colbarlim(1))/(abscontmax-abscontmin); 950 YTick=cont_pos(2:end-1); 951 YTick_scaled=colbarlim(1)+scale_bar*(YTick-abscontmin); 952 set(hcol,'YTick',YTick_scaled); 953 elseif (isfield(PlotParam.Scalar,'CheckBW') && isequal(PlotParam.Scalar.CheckBW,1))||isa(A,'uint8')|| isa(A,'uint16')%images 954 hi=get(hcol,'children'); 955 if iscell(hi)%multiple images in colorbar 956 hi=hi{1}; 957 end 958 set(hi,'YData',[MinA MaxA]) 959 set(hi,'CData',(1:256)') 960 set(hcol,'YLim',[MinA MaxA]) 961 YTick=colbartick(MinA,MaxA); 962 set(hcol,'YTick',YTick) 963 else 964 hi=get(hcol,'children'); 965 if iscell(hi)%multiple images in colorbar 966 hi=hi{1}; 967 end 968 set(hi,'YData',[MinA MaxA]) 969 set(hi,'CData',(1:64)') 970 YTick=colbartick(MinA,MaxA); 971 set(hcol,'YLim',[MinA MaxA]) 972 set(hcol,'YTick',YTick) 973 end 974 set(hcol,'Yticklabel',num2str(YTick')); 975 end 976 elseif ishandle(hcol) 977 delete(hcol); %erase existing colorbar if not needed 978 end 994 979 end 995 980 else%no scalar plot … … 997 982 delete(hima) 998 983 end 999 if ~isempty( hcol)&& ishandle(hcol)984 if ~isempty(PosColorbar) && ~isempty(hcol)&& ishandle(hcol) 1000 985 delete(hcol) 1001 986 end … … 1100 1085 PlotParamOut=rmfield(PlotParamOut,'Vectors'); 1101 1086 end 1102 1103 %listfields={'AY','AX','A','X','Y','U','V','C','W','F','FF'}; 1104 %listdim={'AY','AX',{'AY','AX'},'nb_vectors','nb_vectors','nb_vectors','nb_vectors','nb_vectors','nb_vectors','nb_vectors','nb_vectors'}; 1105 %Role={'coord_y','coord_x','scalar','coord_x','coord_y','vector_x','vector_y','scalar','vector_z','warnflag','errorflag'}; 1106 %ind_select=[]; 1107 nbvar=0; 1087 % nbvar=0; 1108 1088 1109 1089 %store the coordinate extrema occupied by the field … … 1140 1120 end 1141 1121 end 1142 % PlotParamOut.RangeX=[XMin XMax]; %range of x, to be stored in the user data of the plot axes 1143 % PlotParamOut.RangeY=[YMin YMax]; %range of x, to be stored in the user data of the plot axes 1144 % if ~fix_lim 1145 PlotParamOut.Coordinates.MinX=XMin; 1146 PlotParamOut.Coordinates.MaxX=XMax; 1147 PlotParamOut.Coordinates.MinY=YMin; 1148 PlotParamOut.Coordinates.MaxY=YMax; 1149 if XMax>XMin 1150 set(haxes,'XLim',[XMin XMax]);% set x limits of frame in axes coordinates 1151 end 1152 if YMax>YMin 1153 set(haxes,'YLim',[YMin YMax]);% set x limits of frame in axes coordinates 1154 end 1155 % end 1122 PlotParamOut.Coordinates.MinX=XMin; 1123 PlotParamOut.Coordinates.MaxX=XMax; 1124 PlotParamOut.Coordinates.MinY=YMin; 1125 PlotParamOut.Coordinates.MaxY=YMax; 1126 if XMax>XMin 1127 set(haxes,'XLim',[XMin XMax]);% set x limits of frame in axes coordinates 1128 end 1129 if YMax>YMin 1130 set(haxes,'YLim',[YMin YMax]);% set x limits of frame in axes coordinates 1131 end 1156 1132 set(haxes,'YDir','normal') 1157 1133 set(get(haxes,'XLabel'),'String',[XName ' (' x_units ')']); … … 1160 1136 PlotParamOut.Coordinates.y_units=y_units; 1161 1137 end 1162 1163 1164 1165 1166 1167 1168 1169 1138 if isfield(PlotParam,'Coordinates') && isfield(PlotParam.Coordinates,'CheckFixAspectRatio') && isequal(PlotParam.Coordinates.CheckFixAspectRatio,1) 1139 set(haxes,'DataAspectRatioMode','manual') 1140 if isfield(PlotParam.Coordinates,'AspectRatio') 1141 set(haxes,'DataAspectRatio',[PlotParam.Coordinates.AspectRatio 1 1]) 1142 end 1143 else 1144 set(haxes,'DataAspectRatioMode','auto') 1145 end 1170 1146 %------------------------------------------------------------------- 1171 1147 % --- function for plotting vectors
Note: See TracChangeset
for help on using the changeset viewer.