Changeset 1744 for issm/trunk/src/m/classes/public/plot/plot_quiver.m
- Timestamp:
- 08/18/09 09:50:07 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.