Index: /issm/trunk/src/m/classes/public/plot/parse_options.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/parse_options.m	(revision 1743)
+++ /issm/trunk/src/m/classes/public/plot/parse_options.m	(revision 1744)
@@ -23,4 +23,20 @@
 else
 	options_struct.density=NaN;
+end
+
+%scaling
+scalingvalues=findarg(optionstring,'scaling');
+if ~isempty(scalingvalues),
+	options_struct.scaling=scalingvalues(1).value;
+else
+	options_struct.scaling=NaN;
+end
+
+%colorlevels
+colorlevels_values=findarg(optionstring,'colorlevels');
+if ~isempty(colorlevels_values),
+	options_struct.colorlevels=colorlevels_values.value;
+else
+	options_struct.colorlevels=NaN;
 end
 
Index: /issm/trunk/src/m/classes/public/plot/plot_manager.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_manager.m	(revision 1743)
+++ /issm/trunk/src/m/classes/public/plot/plot_manager.m	(revision 1744)
@@ -59,13 +59,4 @@
 		case 'penalties',
 			plot_penalties(md,options_structure,width,i);
-			return;
-		case 'quiver',
-			plot_quiver(md,options_structure,width,i);
-			return;
-		case 'quiver3',
-			plot_quiver3(md,options_structure,width,i);
-			return;
-		case 'quivervel',
-			plot_quivervel(md,options_structure,width,i);
 			return;
 		case 'riftvel',
Index: /issm/trunk/src/m/classes/public/plot/plot_quiver.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_quiver.m	(revision 1743)
+++ /issm/trunk/src/m/classes/public/plot/plot_quiver.m	(revision 1744)
@@ -1,33 +1,77 @@
-function plot_quivervel(md,options_structure,width,i);
-%PLOT_QUIVERVEL - plot arrow field of 2d velocities
+function plot_quiver(x,y,u,v,options_structure),
+%PLOT_QUIVER - quiver plot with colors
+%
+%   to be perfected tomorrow
 %
 %   Usage:
-%      plot_quivervel(md,options_structure,width,i);
+%      plot_quiver(x,y,u,v,options_structure)
 %
-%   See also: PLOTMODEL
+%   Example:
+%      plot_quiver(md.x,md.y,md.vx,md.vy,options_structure);
 
-%process data and model
-[x y z elements is2d]=processmesh(md,options_structure);
-[vx isongrid isquiver]=processdata(md,md.vx,options_structure);
-[vy isongrid isquiver]=processdata(md,md.vy,options_structure);
+%get norm Min and Max
+Norm=sqrt(u.^2+v.^2);
+Min=min(Norm);
+Max=max(Norm);
 
-%plot mesh quivervel
-subplot(width,width,i); 
-					
-%quiver 2d 
-if ~isnan(options_structure.density)
-	x=x(1:options_structure.density:end);
-	y=y(1:options_structure.density:end);
-	vx=vx(1:options_structure.density:end);
-	vy=vy(1:options_structure.density:end);
+%process options: scaling factor?
+if isnan(options_structure.scaling),
+	arrow=0.40;
+else
+	arrow=options_structure.scaling;
 end
-quiver(x,y,vx,vy);
 
-%apply options
-if isnan(options_structure.title)
-	options_structure.title='Velocity vectors';
-end 
-if isnan(options_structure.colorbar)
-	options_structure.colorbar=0;
+%number of colors?
+if isnumeric(options_structure.colorlevels),
+	if isnan(options_structure.colorlevels),
+		numcolors=30;
+	else
+		numcolors=options_structure.colorlevels;
+	end
+	levels=round_ice(linspace(Min,Max,numcolors+1),2);
+else
+	levels=zeros(1,length(options_structure.colorlevels)+2);
+	levels(1)=Min;
+	for i=1:length(options_structure.colorlevels)
+		levels(i+1)=options_structure.colorlevels{i};
+	end
+	levels(end)=Max;
+	levels=sort(unique(levels));
+	numcolors=length(levels)-1;
 end
-applyoptions(md,[],options_structure);
+
+%set the colormap 
+if numcolors==2;
+	%blue and red
+	c=[0 0 1;1 0 0];
+elseif numcolors==3,
+	%blue yellow and red
+	c=[0 0 1;1 1 0;1 0 0];
+else
+	%let jet choose
+	c=colormap(jet(numcolors));
+end
+
+%Scale data
+delta=((min(x)-max(x))^2+(min(y)-max(y))^2)/numel(x);
+u=arrow*sqrt(delta)*u./Norm;
+v=arrow*sqrt(delta)*v./Norm;
+
+%loop over the number of colors
+hold on
+h=[];
+for i=1:numcolors
+	pos=find( (Norm>=levels(i)) & (Norm<=levels(i+1)) );
+	hprime=quiver(x(pos),y(pos),u(pos),v(pos),'Color',c(i,:),'ShowArrowHead','on','AutoScale','off');
+	h=[h;hprime];
+end
+
+%take care of colorbar
+if  0 & ~strcmpi(options_structure.colorbar,'off'),
+	for i=1:length(levels),
+		scalevalues(i)=levels(i);
+		scalestring=[scalestring; sprintf('%8.4g',levels(i))];
+	end
+	set(colorbar,'YTickLabel',scalestring,'YTick',scalevalues);
+	error('debug')
+end
Index: /issm/trunk/src/m/classes/public/plot/plot_quiver3.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_quiver3.m	(revision 1743)
+++ /issm/trunk/src/m/classes/public/plot/plot_quiver3.m	(revision 1744)
@@ -1,36 +1,78 @@
-function plot_quivervel3(md,options_structure,width,i);
-%PLOT_QUIVERVEL3 - plot arrow field of 3d velocities
+function plot_quiver3(x,y,z,u,v,w,options_structure),
+%PLOT_QUIVER3 - 3d quiver plot with colors
+%
+%   to be perfected tomorrow
 %
 %   Usage:
-%      plot_quivervel3(md,options_structure,width,i);
+%      plot_quiver3(x,y,z,u,v,w,options_structure)
 %
-%   See also: PLOTMODEL
+%   Example:
+%      plot_quiver(md.x,md.y,md.z,md.vx,md.vy,md.vz,options_structure);
 
-%process data and model
-[x y z elements is2d]=processmesh(md,options_structure);
-[vx isongrid isquiver]=processdata(md,md.vx,options_structure);
-[vy isongrid isquiver]=processdata(md,md.vy,options_structure);
-[vz isongrid isquiver]=processdata(md,md.vz,options_structure);
+%get norm Min and Max
+Norm=sqrt(u.^2+v.^2+w.^2);
+Min=min(Norm);
+Max=max(Norm);
 
-%plot mesh quivervel3
-subplot(width,width,i); 
+%process options: scaling factor?
+if isnan(options_structure.scaling),
+	arrow=0.40;
+else
+	arrow=options_structure.scaling;
+end
 
-%quiver 3d 
-if ~isnan(options_structure.density)
-	x=x(1:options_structure.density:end);
-	y=y(1:options_structure.density:end);
-	z=z(1:options_structure.density:end);
-	vx=vx(1:options_structure.density:end);
-	vy=vy(1:options_structure.density:end);
-	vz=vz(1:options_structure.density:end);
+%number of colors?
+if isnumeric(options_structure.colorlevels),
+	if isnan(options_structure.colorlevels),
+		numcolors=30;
+	else
+		numcolors=options_structure.colorlevels;
+	end
+	levels=round_ice(linspace(Min,Max,numcolors+1),2);
+else
+	levels=zeros(1,length(options_structure.colorlevels)+2);
+	levels(1)=Min;
+	for i=1:length(options_structure.colorlevels)
+		levels(i+1)=options_structure.colorlevels{i};
+	end
+	levels(end)=Max;
+	levels=sort(unique(levels));
+	numcolors=length(levels)-1;
 end
-quiver3(x,y,z,vx,vy,vz);
 
-%apply options
-if isnan(options_structure.title)
-	options_structure.title='Velocity vectors (3D)';
-end 
-if isnan(options_structure.colorbar)
-	options_structure.colorbar=1;
+%set the colormap 
+if numcolors==2;
+	%blue and red
+	c=[0 0 1;1 0 0];
+elseif numcolors==3,
+	%blue yellow and red
+	c=[0 0 1;1 1 0;1 0 0];
+else
+	%let jet choose
+	c=colormap(jet(numcolors));
 end
-applyoptions(md,[],options_structure);
+
+%Scale data
+delta=((min(x)-max(x))^2+(min(y)-max(y))^2)/numel(x);
+u=arrow*sqrt(delta)*u./Norm;
+v=arrow*sqrt(delta)*v./Norm;
+w=arrow*sqrt(delta)*w./Norm;
+
+%loop over the number of colors
+hold on
+h=[];
+for i=1:numcolors
+	pos=find( (Norm>=levels(i)) & (Norm<=levels(i+1)) );
+	hprime=quiver3(x(pos),y(pos),z(pos),u(pos),v(pos),w(pos),'Color',c(i,:),'ShowArrowHead','on','AutoScale','off');
+	h=[h;hprime];
+end
+
+%take care of colorbar
+if  0 & ~strcmpi(options_structure.colorbar,'off'),
+	for i=1:length(levels),
+		scalevalues(i)=levels(i);
+		scalestring=[scalestring; sprintf('%8.4g',levels(i))];
+	end
+	set(colorbar,'YTickLabel',scalestring,'YTick',scalevalues);
+	error('debug')
+end
Index: sm/trunk/src/m/classes/public/plot/plot_quivervel.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_quivervel.m	(revision 1743)
+++ 	(revision )
@@ -1,51 +1,0 @@
-function plot_quivervel(md,options_structure,width,i);
-%PLOT_QUIVERVEL - superimpose arrows and magnitude of the velocity
-%
-%   Usage:
-%      plot_quivervel(md,options_structure,width,i);
-%
-%   See also: PLOTMODEL, PLOT_UNIT, PLOT_MANAGER
-
-%process data and model
-[x y z elements is2d]=processmesh(md,options_structure);
-[vx isongrid isquiver]=processdata(md,md.vx,options_structure);
-[vy isongrid isquiver]=processdata(md,md.vy,options_structure);
-if ~isnan(md.vz)
-	[vz isongrid isquiver]=processdata(md,md.vz,options_structure);
-end
-
-%density
-if ~isnan(options_structure.density)
-	x=x(1:options_structure.density:end);
-	y=y(1:options_structure.density:end);
-	z=z(1:options_structure.density:end);
-	vx=vx(1:options_structure.density:end);
-	vy=vy(1:options_structure.density:end);
-	vz=vz(1:options_structure.density:end);
-end
-
-%plot
-subplot(width,width,i); 
-colormap('default')
-plot_unit(x,y,z,elements,sqrt(vx.^2+vy.^2),isongrid,is2d,isquiver,options_structure)
-
-if is2d
-	hold on
-	colorbar;
-	quiver(x,y,vx,vy,'k')
-	alpha(0.7)
-else
-	hold on
-	colorbar;
-	quiver3(x,y,z,vx,vy,vz);
-	alpha(0.7)
-end
-
-%apply options
-if isnan(options_structure.title)
-	options_structure.title='Velocity';
-end 
-if isnan(options_structure.colorbar)
-	options_structure.colorbar=1;
-end
-applyoptions(md,[],options_structure);
Index: /issm/trunk/src/m/classes/public/plot/plot_unit.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_unit.m	(revision 1743)
+++ /issm/trunk/src/m/classes/public/plot/plot_unit.m	(revision 1744)
@@ -53,7 +53,7 @@
 	if isongrid,
 		if is2d,
-			quivercolor(x,y,data(:,1),data(:,2));
+			plot_quiver(x,y,data(:,1),data(:,2),options_structure);
 		else
-			quivercolor3(x,y,z,data(:,1),data(:,2),data(:,3));
+			plot_quiver3(x,y,z,data(:,1),data(:,2),data(:,3),options_structure);
 		end
 	else
Index: /issm/trunk/src/m/classes/public/plot/plotdoc.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plotdoc.m	(revision 1743)
+++ /issm/trunk/src/m/classes/public/plot/plotdoc.m	(revision 1744)
@@ -12,8 +12,11 @@
 disp('                Available values for ''data'' are: ');
 disp('                  - any field of the model structure. ex: plot(md,''data'',''vel''), or plot(md,''data'',md.vel)');
+disp('                  - ''basal_drag'': plot the basal drag on the bed (in kPa)');
+disp('                  - ''basal_dragx'' or ''basal_dragy'' : plot a component of the basal drag on the bed (in kPa)');
 disp('                  - ''boundaries'': this will draw all the segment boundaries to the model, including rifts.');
 disp('                  - ''deviatoricstress_tensor'': plot the components of the deviatoric stress tensor (tauxx,tauyy,tauzz,tauxy,tauxz,tauyz) if computed');
 disp('                  - ''deviatoricstress_principal'': plot the deviatoricstress tensor principal axis and principal values');
 disp('                  - ''deviatoricstress_principalaxis1'': arrow plot the first principal axis of the deviatoricstress tensor(replace 1 by 2 or 3 if needed)');
+disp('                  - ''driving_stress'': plot the driving stress (in kPa)');
 disp('                  - ''elements_type'': model used for each element');
 disp('                  - ''elementnumbering'': numbering of elements');
@@ -23,13 +26,7 @@
 disp('                  - ''highlightgrids'': to highlight grids (use highlight option to enter the grid list');
 disp('                  - ''mesh'': draw mesh using trisurf');
-disp('                  - ''quiver'': arrow plot of the velocity in 2d');
-disp('                  - ''quiver3'': arrow plot of the velocity in 3d');
-disp('                  - ''quivervel'': arrow plot of the velocity superimposed with its magnitude');
 disp('                  - ''riftvel'': velocities along rifts');
 disp('                  - ''riftrelvel'': relative velocities along rifts');
 disp('                  - ''riftpenetration'': penetration levels for a fault');
-disp('                  - ''basal_drag'': plot the basal drag on the bed (in kPa)');
-disp('                  - ''basal_dragx'' or ''basal_dragy'' : plot a component of the basal drag on the bed (in kPa)');
-disp('                  - ''driving_stress'': plot the driving stress (in kPa)');
 disp('                  - ''strainrate_tensor'': plot the components of the strainrate tensor (exx,eyy,ezz,exy,exz,eyz) if computed');
 disp('                  - ''strainrate_principal'': plot the strainrate tensor principal axis and principal values)');
@@ -54,4 +51,5 @@
 disp('       ''antzoom'': zoom on a given Antarctic basin (''pineislandglacier'',''ronneiceshelf'', type antzoom for a complete list)');
 disp('       ''caxis'': modify  colorbar range. (array of type [a b] where b>=a)');
+disp('       ''colorlevels'':  N or {value1,valu2,value3,...} used if quiver, use different colors for the given number of colors or limits');
 disp('       ''colorbar'': add colorbar (string ''on'' or ''off'')');
 disp('       ''colorbarpos'': [x,y,dx,dy] where x,y,dx and dy are within [0 1]');
@@ -63,5 +61,4 @@
 disp('       ''density'': density of quivers (one arrow every N nodes, N integer)');
 disp('       ''streamlines'': N (number of stream lines) or {[x1 y1],...} (coordinates of seed points) add streanlines on current figure');
-disp('       ''wrapping'': repeat ''n'' times the colormap (''n'' must be an integer)');
 disp('       ''edgecolor'': same as standard matlab option EdgeColor (color name: ''black'' or RGB array: [0.5 0.2 0.8])');
 disp('       ''fontsize'': same as standard matlab option (normal: ''n'',bold: ''b'',light: ''l'',demi: ''d'')');
@@ -103,4 +100,5 @@
 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');
 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');
+disp('       ''wrapping'': repeat ''n'' times the colormap (''n'' must be an integer)');
 disp(' ');
 disp('       any options (except ''data'') can be followed by ''#i'' where ''i'' is the subplot number, or ''#all'' if applied to all plots');
Index: /issm/trunk/src/m/classes/public/plot/processdata.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/processdata.m	(revision 1743)
+++ /issm/trunk/src/m/classes/public/plot/processdata.m	(revision 1744)
@@ -115,2 +115,10 @@
 	data=project2d(md,data,options_structure.layer); %project onto 2d mesh
 end
+
+%control arrow density if quiverplot
+if isquiver & ~isnan(options_structure.density)
+	databak=data;
+	data=NaN*ones(datasize);
+	data(1:options_structure.density:end,:)=databak(1:options_structure.density:end,:);
+	clear databak
+end
Index: sm/trunk/src/m/classes/public/plot/quivercolor.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/quivercolor.m	(revision 1743)
+++ 	(revision )
@@ -1,38 +1,0 @@
-function h=quivercolor(x,y,u,v),
-%QUIVERCOLOR - quiver plot with colors
-%
-%   to be perfected tomorrow
-%
-%   Usage:
-%      h=quivercolor(x,y,u,v)
-%
-%   Example:
-%      quivercolor(md.x,md.y,md.vx,md.vy);
-
-%number of colors
-numcolors=40;
-%Set arrow size (1= full length of vector)
-arrow=0.40;
-
-%set the colormap 
-c=colormap(jet(numcolors));
-h=[];
-
-%get norm Min and Max
-Norm=sqrt(u.^2+v.^2);
-Min=min(Norm);
-Max=max(Norm);
-Interval=(Max-Min)/numcolors;
-
-%Get scaling factor
-delta=((min(x)-max(x))^2+(min(y)-max(y))^2)/numel(x);
-u=arrow*sqrt(delta)*u./Norm;
-v=arrow*sqrt(delta)*v./Norm;
-
-%loop over the number of colors
-hold on
-for i=1:numcolors
-	pos=find( (Norm>=Min+(i-1)*Interval) & (Norm<=Min+i*Interval) );
-	hprime=quiver(x(pos),y(pos),u(pos),v(pos),'Color',c(i,:),'ShowArrowHead','on','AutoScale','off');
-	h=[h;hprime];
-end
