plot_section

PURPOSE ^

PLOT_SECTION - plot a given field on a section

SYNOPSIS ^

function plot_section(md,data,options_structure,width,i)

DESCRIPTION ^

PLOT_SECTION - plot a given field on a section

   Usage:
      plot_section(md,options_structure,width,i);

   See also: PLOTMODEL

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function plot_section(md,data,options_structure,width,i)
0002 %PLOT_SECTION - plot a given field on a section
0003 %
0004 %   Usage:
0005 %      plot_section(md,options_structure,width,i);
0006 %
0007 %   See also: PLOTMODEL
0008 
0009 %How many subplots?
0010 if strcmpi(options_structure.showsection,'yes')
0011 
0012     %Compute the indexes of the 2 plots (one for the sectionvalue and one for showsection
0013     upperplots=fix((i-1)/width);
0014     if upperplots==0, leftplots=i-1; else leftplots=i-width*upperplots-1; end
0015     index1=4*width*upperplots+2*leftplots+1;
0016     index2=index1+1;
0017     width=2*width;
0018 else
0019     index1=i;
0020 end
0021 
0022 %check on arguments
0023 if (iscell(data) | isempty(data)),
0024     error('plot error message: data provided is empty');
0025 end
0026 if md.numberofgrids==size(md.elements,1),
0027     error('plot error message: the number of elements is the same as the number of grids! cannot plot anything with model/plot, use matlab/plot instead')
0028 end
0029 
0030 %smoothing?
0031 if strcmpi(options_structure.smooth,'yes') & length(data)==md.numberofelements
0032     data=elementstogrids(md,data);
0033 end
0034 
0035 %layer projection?
0036 if ~isnan(options_structure.layer) & options_structure.layer>=1,
0037     data=project2d(md,data,options_structure.layer); %project onto 2d mesh
0038     %we modify the mesh temporarily to a 2d mesh from which the 3d mesh was extruded.
0039     md.x=md.x2d;
0040     md.y=md.y2d;
0041     md.z=md.z2d;
0042     md.elements=md.elements2d;
0043     md.elements_type=md.elements_type2d;
0044     md.type='2d';
0045 end
0046 
0047 %units
0048 if ~isnan(options_structure.unitmultiplier),
0049     md.x=md.x*options_structure.unitmultiplier;
0050     md.y=md.y*options_structure.unitmultiplier;
0051     md.z=md.z*options_structure.unitmultiplier;
0052 end
0053 
0054 %resolution
0055 if ~isnan(options_structure.resolution),
0056     resolution=options_structure.resolution;
0057 else %Default resolution
0058     resolution=[1000 10*md.numlayers];
0059     disp(['plot_section warning: no resolution specified, use default resolution: [horizontal_resolution vertical_resolution]=[' num2str(resolution)  ']']);
0060 end
0061 
0062 %Compute section value
0063 [elements,x,y,z,s,data]=SectionValues(md,data,options_structure.sectionvalue,resolution);
0064 
0065 if strcmpi(md.type,'2d')
0066     %plot section value
0067     subplot(width,width,index1)
0068     plot(s,data)
0069 else
0070     %plot section value
0071     %if user requested view2: 2d plot with curvilinear coordinate
0072     if (~isnan(options_structure.view) & options_structure.view==2 )
0073         subplot(width,width,index1)
0074         A=elements(:,1); B=elements(:,2); C=elements(:,3);  D=elements(:,4); 
0075         patch( 'Faces', [A B C D], 'Vertices', [s z zeros(length(s),1)],'FaceVertexCData',data,'FaceColor','interp','EdgeColor','none');
0076     else
0077         subplot(width,width,index1)
0078         A=elements(:,1); B=elements(:,2); C=elements(:,3);  D=elements(:,4); 
0079         patch( 'Faces', [A B C D], 'Vertices', [x y z],'FaceVertexCData',data,'FaceColor','interp','EdgeColor','none');
0080         view(3)
0081     end
0082 end
0083 
0084 %apply options
0085 if isnan(options_structure.title)
0086     options_structure.title='Section value';
0087 end 
0088 if isnan(options_structure.colorbar) & strcmpi(md.type,'2d')
0089     options_structure.colorbar=0;
0090 end
0091 if isnan(options_structure.xlabel) & (strcmpi(md.type,'2d') | options_structure.view==2 )
0092     options_structure.xlabel='Curvilinear coordinate';
0093 end
0094 if isnan(options_structure.ylabel) & (strcmpi(md.type,'3d') & options_structure.view==2 )
0095     options_structure.ylabel='z';
0096 end
0097 applyoptions(md,[],options_structure);
0098 
0099 %plot section if requested by user
0100 if strcmpi(options_structure.showsection,'yes')
0101     subplot(width,width,index2)
0102     hold on
0103     text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8])
0104     text(x(end),y(end),'end','backgroundcolor',[0.8 0.9 0.8])
0105     plot(x,y)
0106     axis([min(md.x) max(md.x) min(md.y) max(md.y)])
0107     view(2)
0108 end

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003