Index: /issm/trunk/src/m/classes/public/plot/plot_section.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_section.m	(revision 5831)
+++ /issm/trunk/src/m/classes/public/plot/plot_section.m	(revision 5832)
@@ -20,74 +20,35 @@
 end
 
-%process data and model
+%process model
 [x_m y_m z_m elements_m is2d]=processmesh(md,[],options);
-[data datatype]=processdata(md,data,options);
 
-%replug x and y onto model so that SectionValue treats the problem correctly
-if exist(options,'layer')
-	md.x=md.x2d; md.y=md.y2d; md.elements=md.elements2d; md.dim=2;
-end
+%Get number of curves and generate random colors
+numcurves=size(data,2);
+colorm=getfieldvalue(options,'colormap','jet');
+eval(['color=' colorm '(numcurves);']);
 
-%resolution
-if exist(options,'resolution'),
-	resolution=getfieldvalue(options,'resolution');
-else %Default resolution
-	resolution=[1000 10*md.numlayers];
-	disp(['plot_section warning: no resolution specified, use default resolution: [horizontal_resolution vertical_resolution]=[' num2str(resolution)  ']']);
-end
+%Loop over number of curves
+for i=1:numcurves,
 
-%Compute section value
-if datatype==3,
-	[elements,x,y,z,s,data_s1]=SectionValues(md,data(:,1),getfieldvalue(options,'sectionvalue'),resolution);
-	[elements,x,y,z,s,data_s2]=SectionValues(md,data(:,2),getfieldvalue(options,'sectionvalue'),resolution);
-else
-	[elements,x,y,z,s,data_s]=SectionValues(md,data,getfieldvalue(options,'sectionvalue'),resolution);
-end
+	[datai datatype]=processdata(md,data(:,i),options);
 
-%2D
-if is2d
-
-	%Show Section if requested by user
-	if exist(options,'showsection')
-
-		%compute number of labels
-		numlabels=min(getfieldvalue(options,'showsection'),length(s));
-		shift=fix(length(s)/numlabels);
-
-		%plot labels on current graph
-		hold on
-		text(s(1),data_s(1),'1','backgroundcolor',[0.8 0.9 0.8])
-		for i=2:numlabels-1
-			text(s(1+(i-1)*shift),data_s(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8])
-		end
-		text(s(end),data_s(end),'end','backgroundcolor',[0.8 0.9 0.8])
-
-		%plot section only with labels
-		subplot(width,width,index2)
-		plot_unit(x_m,y_m,z_m,elements_m,data,is2d,datatype,options)
-		hold on
-		text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8])
-		for i=2:numlabels-1
-			text(x(1+(i-1)*shift),y(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8])
-		end
-		text(x(end),y(end),'end','backgroundcolor',[0.8 0.9 0.8])
-		plot(x,y,'-r')
-		axis([min(md.x)-1 max(md.x)+1 min(md.y)-1 max(md.y)+1])
-		view(2)
+	%replug x and y onto model so that SectionValue treats the problem correctly
+	if exist(options,'layer')
+		md.x=md.x2d; md.y=md.y2d; md.elements=md.elements2d; md.dim=2;
 	end
 
-	%plot section value
-	subplot(width,width,index1)
-	if datatype==3,
-		plot(s,data_s1,s,data_s2);
-	else
-		plot(s,data_s)
+	%resolution
+	if exist(options,'resolution'),
+		resolution=getfieldvalue(options,'resolution');
+	else %Default resolution
+		resolution=[1000 10*md.numlayers];
+		disp(['plot_section warning: no resolution specified, use default resolution: [horizontal_resolution vertical_resolution]=[' num2str(resolution)  ']']);
 	end
 
-%3D
-else
-	%plot section value
-	%if user requested view2: 2d plot with curvilinear coordinate
-	if (getfieldvalue(options,'view',3)==2 )
+	%Compute section value
+	[elements,x,y,z,s,data_s]=SectionValues(md,datai,getfieldvalue(options,'sectionvalue'),resolution);
+
+	%2D
+	if is2d
 
 		%Show Section if requested by user
@@ -100,13 +61,13 @@
 			%plot labels on current graph
 			hold on
-			text(s(1),z(1),'1','backgroundcolor',[0.8 0.9 0.8])
+			text(s(1),data_s(1),'1','backgroundcolor',[0.8 0.9 0.8])
 			for i=2:numlabels-1
-				text(s(1+(i-1)*shift),z(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8])
+				text(s(1+(i-1)*shift),data_s(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8])
 			end
-			text(s(end),z(end),'end','backgroundcolor',[0.8 0.9 0.8])
+			text(s(end),data_s(end),'end','backgroundcolor',[0.8 0.9 0.8])
 
 			%plot section only with labels
 			subplot(width,width,index2)
-			plot_unit(x_m,y_m,z_m,elements_m,data,is2d,datatype,options)
+			plot_unit(x_m,y_m,z_m,elements_m,data(:,i),is2d,datatype,options)
 			hold on
 			text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8])
@@ -120,44 +81,85 @@
 		end
 
+		%plot section value
+		hold on;
 		subplot(width,width,index1)
-		A=elements(:,1); B=elements(:,2); C=elements(:,3);  D=elements(:,4); 
-		patch( 'Faces', [A B C D], 'Vertices', [s z zeros(length(s),1)],'FaceVertexCData',data_s,'FaceColor','interp','EdgeColor','none');
+		plot(s,data_s,'color',color(i,:))
 
+		%3D
 	else
+		%plot section value
+		%if user requested view2: 2d plot with curvilinear coordinate
+		if (getfieldvalue(options,'view',3)==2 )
 
-		%Show Section if requested by user
-		if exist(options,'showsection')
+			%Show Section if requested by user
+			if exist(options,'showsection')
 
-			%compute number of labels
-			numlabels=min(getfieldvalue(options,'showsection'),length(s));
-			shift=fix(length(x)/numlabels);
+				%compute number of labels
+				numlabels=min(getfieldvalue(options,'showsection'),length(s));
+				shift=fix(length(s)/numlabels);
 
-			%plot labels on current graph
-			hold on
-			text(x(1),y(1),z(1),'1','backgroundcolor',[0.8 0.9 0.8])
-			for i=2:numlabels-1
-				text(x(1+(i-1)*shift),y(1+(i-1)*shift),z(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8])
+				%plot labels on current graph
+				hold on
+				text(s(1),z(1),'1','backgroundcolor',[0.8 0.9 0.8])
+				for i=2:numlabels-1
+					text(s(1+(i-1)*shift),z(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8])
+				end
+				text(s(end),z(end),'end','backgroundcolor',[0.8 0.9 0.8])
+
+				%plot section only with labels
+				subplot(width,width,index2)
+				plot_unit(x_m,y_m,z_m,elements_m,data(:,i),is2d,datatype,options)
+				hold on
+				text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8])
+				for i=2:numlabels-1
+					text(x(1+(i-1)*shift),y(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8])
+				end
+				text(x(end),y(end),'end','backgroundcolor',[0.8 0.9 0.8])
+				plot(x,y,'-r')
+				axis([min(md.x)-1 max(md.x)+1 min(md.y)-1 max(md.y)+1])
+				view(2)
 			end
-			text(x(end),y(end),z(end),'end','backgroundcolor',[0.8 0.9 0.8])
 
-			%plot section only with labels
-			subplot(width,width,index2)
-			plot_unit(x_m,y_m,z_m,elements_m,data,is2d,datatype,options)
-			hold on
-			text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8])
-			for i=2:numlabels-1
-				text(x(1+(i-1)*shift),y(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8])
+			subplot(width,width,index1)
+			A=elements(:,1); B=elements(:,2); C=elements(:,3);  D=elements(:,4); 
+			patch( 'Faces', [A B C D], 'Vertices', [s z zeros(length(s),1)],'FaceVertexCData',data_s,'FaceColor','interp','EdgeColor','none');
+
+		else
+
+			%Show Section if requested by user
+			if exist(options,'showsection')
+
+				%compute number of labels
+				numlabels=min(getfieldvalue(options,'showsection'),length(s));
+				shift=fix(length(x)/numlabels);
+
+				%plot labels on current graph
+				hold on
+				text(x(1),y(1),z(1),'1','backgroundcolor',[0.8 0.9 0.8])
+				for i=2:numlabels-1
+					text(x(1+(i-1)*shift),y(1+(i-1)*shift),z(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8])
+				end
+				text(x(end),y(end),z(end),'end','backgroundcolor',[0.8 0.9 0.8])
+
+				%plot section only with labels
+				subplot(width,width,index2)
+				plot_unit(x_m,y_m,z_m,elements_m,data,is2d,datatype,options)
+				hold on
+				text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8])
+				for i=2:numlabels-1
+					text(x(1+(i-1)*shift),y(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8])
+				end
+				text(x(end),y(end),'end','backgroundcolor',[0.8 0.9 0.8])
+				plot(x,y,'-r')
+				axis([min(md.x)-1 max(md.x)+1 min(md.y)-1 max(md.y)+1])
+				view(2)
 			end
-			text(x(end),y(end),'end','backgroundcolor',[0.8 0.9 0.8])
-			plot(x,y,'-r')
-			axis([min(md.x)-1 max(md.x)+1 min(md.y)-1 max(md.y)+1])
-			view(2)
+
+			subplot(width,width,index1)
+			A=elements(:,1); B=elements(:,2); C=elements(:,3);  D=elements(:,4); 
+			patch( 'Faces', [A B C D], 'Vertices', [x y z],'FaceVertexCData',data_s,'FaceColor','interp','EdgeColor','none');
+			view(3)
+
 		end
-
-		subplot(width,width,index1)
-		A=elements(:,1); B=elements(:,2); C=elements(:,3);  D=elements(:,4); 
-		patch( 'Faces', [A B C D], 'Vertices', [x y z],'FaceVertexCData',data_s,'FaceColor','interp','EdgeColor','none');
-		view(3)
-
 	end
 end
