Changeset 1744
- Timestamp:
- 08/18/09 09:50:07 (16 years ago)
- Location:
- issm/trunk/src/m/classes/public/plot
- Files:
-
- 2 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/classes/public/plot/parse_options.m
r1606 r1744 23 23 else 24 24 options_struct.density=NaN; 25 end 26 27 %scaling 28 scalingvalues=findarg(optionstring,'scaling'); 29 if ~isempty(scalingvalues), 30 options_struct.scaling=scalingvalues(1).value; 31 else 32 options_struct.scaling=NaN; 33 end 34 35 %colorlevels 36 colorlevels_values=findarg(optionstring,'colorlevels'); 37 if ~isempty(colorlevels_values), 38 options_struct.colorlevels=colorlevels_values.value; 39 else 40 options_struct.colorlevels=NaN; 25 41 end 26 42 -
issm/trunk/src/m/classes/public/plot/plot_manager.m
r1740 r1744 59 59 case 'penalties', 60 60 plot_penalties(md,options_structure,width,i); 61 return;62 case 'quiver',63 plot_quiver(md,options_structure,width,i);64 return;65 case 'quiver3',66 plot_quiver3(md,options_structure,width,i);67 return;68 case 'quivervel',69 plot_quivervel(md,options_structure,width,i);70 61 return; 71 62 case 'riftvel', -
issm/trunk/src/m/classes/public/plot/plot_quiver.m
r1740 r1744 1 function plot_quivervel(md,options_structure,width,i); 2 %PLOT_QUIVERVEL - plot arrow field of 2d velocities 1 function plot_quiver(x,y,u,v,options_structure), 2 %PLOT_QUIVER - quiver plot with colors 3 % 4 % to be perfected tomorrow 3 5 % 4 6 % Usage: 5 % plot_quiver vel(md,options_structure,width,i);7 % plot_quiver(x,y,u,v,options_structure) 6 8 % 7 % See also: PLOTMODEL 9 % Example: 10 % plot_quiver(md.x,md.y,md.vx,md.vy,options_structure); 8 11 9 % process data and model10 [x y z elements is2d]=processmesh(md,options_structure);11 [vx isongrid isquiver]=processdata(md,md.vx,options_structure);12 [vy isongrid isquiver]=processdata(md,md.vy,options_structure);12 %get norm Min and Max 13 Norm=sqrt(u.^2+v.^2); 14 Min=min(Norm); 15 Max=max(Norm); 13 16 14 %plot mesh quivervel 15 subplot(width,width,i); 16 17 %quiver 2d 18 if ~isnan(options_structure.density) 19 x=x(1:options_structure.density:end); 20 y=y(1:options_structure.density:end); 21 vx=vx(1:options_structure.density:end); 22 vy=vy(1:options_structure.density:end); 17 %process options: scaling factor? 18 if isnan(options_structure.scaling), 19 arrow=0.40; 20 else 21 arrow=options_structure.scaling; 23 22 end 24 quiver(x,y,vx,vy);25 23 26 %apply options 27 if isnan(options_structure.title) 28 options_structure.title='Velocity vectors'; 29 end 30 if isnan(options_structure.colorbar) 31 options_structure.colorbar=0; 24 %number of colors? 25 if isnumeric(options_structure.colorlevels), 26 if isnan(options_structure.colorlevels), 27 numcolors=30; 28 else 29 numcolors=options_structure.colorlevels; 30 end 31 levels=round_ice(linspace(Min,Max,numcolors+1),2); 32 else 33 levels=zeros(1,length(options_structure.colorlevels)+2); 34 levels(1)=Min; 35 for i=1:length(options_structure.colorlevels) 36 levels(i+1)=options_structure.colorlevels{i}; 37 end 38 levels(end)=Max; 39 levels=sort(unique(levels)); 40 numcolors=length(levels)-1; 32 41 end 33 applyoptions(md,[],options_structure); 42 43 %set the colormap 44 if numcolors==2; 45 %blue and red 46 c=[0 0 1;1 0 0]; 47 elseif numcolors==3, 48 %blue yellow and red 49 c=[0 0 1;1 1 0;1 0 0]; 50 else 51 %let jet choose 52 c=colormap(jet(numcolors)); 53 end 54 55 %Scale data 56 delta=((min(x)-max(x))^2+(min(y)-max(y))^2)/numel(x); 57 u=arrow*sqrt(delta)*u./Norm; 58 v=arrow*sqrt(delta)*v./Norm; 59 60 %loop over the number of colors 61 hold on 62 h=[]; 63 for i=1:numcolors 64 pos=find( (Norm>=levels(i)) & (Norm<=levels(i+1)) ); 65 hprime=quiver(x(pos),y(pos),u(pos),v(pos),'Color',c(i,:),'ShowArrowHead','on','AutoScale','off'); 66 h=[h;hprime]; 67 end 68 69 %take care of colorbar 70 if 0 & ~strcmpi(options_structure.colorbar,'off'), 71 for i=1:length(levels), 72 scalevalues(i)=levels(i); 73 scalestring=[scalestring; sprintf('%8.4g',levels(i))]; 74 end 75 set(colorbar,'YTickLabel',scalestring,'YTick',scalevalues); 76 error('debug') 77 end -
issm/trunk/src/m/classes/public/plot/plot_quiver3.m
r1740 r1744 1 function plot_quivervel3(md,options_structure,width,i); 2 %PLOT_QUIVERVEL3 - plot arrow field of 3d velocities 1 function plot_quiver3(x,y,z,u,v,w,options_structure), 2 %PLOT_QUIVER3 - 3d quiver plot with colors 3 % 4 % to be perfected tomorrow 3 5 % 4 6 % Usage: 5 % plot_quiver vel3(md,options_structure,width,i);7 % plot_quiver3(x,y,z,u,v,w,options_structure) 6 8 % 7 % See also: PLOTMODEL 9 % Example: 10 % plot_quiver(md.x,md.y,md.z,md.vx,md.vy,md.vz,options_structure); 8 11 9 %process data and model 10 [x y z elements is2d]=processmesh(md,options_structure); 11 [vx isongrid isquiver]=processdata(md,md.vx,options_structure); 12 [vy isongrid isquiver]=processdata(md,md.vy,options_structure); 13 [vz isongrid isquiver]=processdata(md,md.vz,options_structure); 12 %get norm Min and Max 13 Norm=sqrt(u.^2+v.^2+w.^2); 14 Min=min(Norm); 15 Max=max(Norm); 14 16 15 %plot mesh quivervel3 16 subplot(width,width,i); 17 %process options: scaling factor? 18 if isnan(options_structure.scaling), 19 arrow=0.40; 20 else 21 arrow=options_structure.scaling; 22 end 17 23 18 %quiver 3d 19 if ~isnan(options_structure.density) 20 x=x(1:options_structure.density:end); 21 y=y(1:options_structure.density:end); 22 z=z(1:options_structure.density:end); 23 vx=vx(1:options_structure.density:end); 24 vy=vy(1:options_structure.density:end); 25 vz=vz(1:options_structure.density:end); 24 %number of colors? 25 if isnumeric(options_structure.colorlevels), 26 if isnan(options_structure.colorlevels), 27 numcolors=30; 28 else 29 numcolors=options_structure.colorlevels; 30 end 31 levels=round_ice(linspace(Min,Max,numcolors+1),2); 32 else 33 levels=zeros(1,length(options_structure.colorlevels)+2); 34 levels(1)=Min; 35 for i=1:length(options_structure.colorlevels) 36 levels(i+1)=options_structure.colorlevels{i}; 37 end 38 levels(end)=Max; 39 levels=sort(unique(levels)); 40 numcolors=length(levels)-1; 26 41 end 27 quiver3(x,y,z,vx,vy,vz);28 42 29 %apply options 30 if isnan(options_structure.title) 31 options_structure.title='Velocity vectors (3D)'; 32 end 33 if isnan(options_structure.colorbar) 34 options_structure.colorbar=1; 43 %set the colormap 44 if numcolors==2; 45 %blue and red 46 c=[0 0 1;1 0 0]; 47 elseif numcolors==3, 48 %blue yellow and red 49 c=[0 0 1;1 1 0;1 0 0]; 50 else 51 %let jet choose 52 c=colormap(jet(numcolors)); 35 53 end 36 applyoptions(md,[],options_structure); 54 55 %Scale data 56 delta=((min(x)-max(x))^2+(min(y)-max(y))^2)/numel(x); 57 u=arrow*sqrt(delta)*u./Norm; 58 v=arrow*sqrt(delta)*v./Norm; 59 w=arrow*sqrt(delta)*w./Norm; 60 61 %loop over the number of colors 62 hold on 63 h=[]; 64 for i=1:numcolors 65 pos=find( (Norm>=levels(i)) & (Norm<=levels(i+1)) ); 66 hprime=quiver3(x(pos),y(pos),z(pos),u(pos),v(pos),w(pos),'Color',c(i,:),'ShowArrowHead','on','AutoScale','off'); 67 h=[h;hprime]; 68 end 69 70 %take care of colorbar 71 if 0 & ~strcmpi(options_structure.colorbar,'off'), 72 for i=1:length(levels), 73 scalevalues(i)=levels(i); 74 scalestring=[scalestring; sprintf('%8.4g',levels(i))]; 75 end 76 set(colorbar,'YTickLabel',scalestring,'YTick',scalevalues); 77 error('debug') 78 end -
issm/trunk/src/m/classes/public/plot/plot_unit.m
r1740 r1744 53 53 if isongrid, 54 54 if is2d, 55 quivercolor(x,y,data(:,1),data(:,2));55 plot_quiver(x,y,data(:,1),data(:,2),options_structure); 56 56 else 57 quivercolor3(x,y,z,data(:,1),data(:,2),data(:,3));57 plot_quiver3(x,y,z,data(:,1),data(:,2),data(:,3),options_structure); 58 58 end 59 59 else -
issm/trunk/src/m/classes/public/plot/plotdoc.m
r1606 r1744 12 12 disp(' Available values for ''data'' are: '); 13 13 disp(' - any field of the model structure. ex: plot(md,''data'',''vel''), or plot(md,''data'',md.vel)'); 14 disp(' - ''basal_drag'': plot the basal drag on the bed (in kPa)'); 15 disp(' - ''basal_dragx'' or ''basal_dragy'' : plot a component of the basal drag on the bed (in kPa)'); 14 16 disp(' - ''boundaries'': this will draw all the segment boundaries to the model, including rifts.'); 15 17 disp(' - ''deviatoricstress_tensor'': plot the components of the deviatoric stress tensor (tauxx,tauyy,tauzz,tauxy,tauxz,tauyz) if computed'); 16 18 disp(' - ''deviatoricstress_principal'': plot the deviatoricstress tensor principal axis and principal values'); 17 19 disp(' - ''deviatoricstress_principalaxis1'': arrow plot the first principal axis of the deviatoricstress tensor(replace 1 by 2 or 3 if needed)'); 20 disp(' - ''driving_stress'': plot the driving stress (in kPa)'); 18 21 disp(' - ''elements_type'': model used for each element'); 19 22 disp(' - ''elementnumbering'': numbering of elements'); … … 23 26 disp(' - ''highlightgrids'': to highlight grids (use highlight option to enter the grid list'); 24 27 disp(' - ''mesh'': draw mesh using trisurf'); 25 disp(' - ''quiver'': arrow plot of the velocity in 2d');26 disp(' - ''quiver3'': arrow plot of the velocity in 3d');27 disp(' - ''quivervel'': arrow plot of the velocity superimposed with its magnitude');28 28 disp(' - ''riftvel'': velocities along rifts'); 29 29 disp(' - ''riftrelvel'': relative velocities along rifts'); 30 30 disp(' - ''riftpenetration'': penetration levels for a fault'); 31 disp(' - ''basal_drag'': plot the basal drag on the bed (in kPa)');32 disp(' - ''basal_dragx'' or ''basal_dragy'' : plot a component of the basal drag on the bed (in kPa)');33 disp(' - ''driving_stress'': plot the driving stress (in kPa)');34 31 disp(' - ''strainrate_tensor'': plot the components of the strainrate tensor (exx,eyy,ezz,exy,exz,eyz) if computed'); 35 32 disp(' - ''strainrate_principal'': plot the strainrate tensor principal axis and principal values)'); … … 54 51 disp(' ''antzoom'': zoom on a given Antarctic basin (''pineislandglacier'',''ronneiceshelf'', type antzoom for a complete list)'); 55 52 disp(' ''caxis'': modify colorbar range. (array of type [a b] where b>=a)'); 53 disp(' ''colorlevels'': N or {value1,valu2,value3,...} used if quiver, use different colors for the given number of colors or limits'); 56 54 disp(' ''colorbar'': add colorbar (string ''on'' or ''off'')'); 57 55 disp(' ''colorbarpos'': [x,y,dx,dy] where x,y,dx and dy are within [0 1]'); … … 63 61 disp(' ''density'': density of quivers (one arrow every N nodes, N integer)'); 64 62 disp(' ''streamlines'': N (number of stream lines) or {[x1 y1],...} (coordinates of seed points) add streanlines on current figure'); 65 disp(' ''wrapping'': repeat ''n'' times the colormap (''n'' must be an integer)');66 63 disp(' ''edgecolor'': same as standard matlab option EdgeColor (color name: ''black'' or RGB array: [0.5 0.2 0.8])'); 67 64 disp(' ''fontsize'': same as standard matlab option (normal: ''n'',bold: ''b'',light: ''l'',demi: ''d'')'); … … 103 100 disp(' ''northarrow'': add an arrow pointing north, ''on'' for default value or [x0 y0 length [ratio [width]]] where (x0,y0) are the coordinates of the base, and ratio=headlength/length'); 104 101 disp(' ''scaleruler'': add a scale ruler, ''on'' for default value or [x0 y0 length width numberofticks] where (x0,y0) are the coordinates of the lower left corner'); 102 disp(' ''wrapping'': repeat ''n'' times the colormap (''n'' must be an integer)'); 105 103 disp(' '); 106 104 disp(' any options (except ''data'') can be followed by ''#i'' where ''i'' is the subplot number, or ''#all'' if applied to all plots'); -
issm/trunk/src/m/classes/public/plot/processdata.m
r1740 r1744 115 115 data=project2d(md,data,options_structure.layer); %project onto 2d mesh 116 116 end 117 118 %control arrow density if quiverplot 119 if isquiver & ~isnan(options_structure.density) 120 databak=data; 121 data=NaN*ones(datasize); 122 data(1:options_structure.density:end,:)=databak(1:options_structure.density:end,:); 123 clear databak 124 end
Note:
See TracChangeset
for help on using the changeset viewer.