Changeset 5832
- Timestamp:
- 09/15/10 16:31:17 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/classes/public/plot/plot_section.m
r4330 r5832 20 20 end 21 21 22 %process data andmodel22 %process model 23 23 [x_m y_m z_m elements_m is2d]=processmesh(md,[],options); 24 [data datatype]=processdata(md,data,options);25 24 26 % replug x and y onto model so that SectionValue treats the problem correctly27 if exist(options,'layer') 28 md.x=md.x2d; md.y=md.y2d; md.elements=md.elements2d; md.dim=2;29 e nd25 %Get number of curves and generate random colors 26 numcurves=size(data,2); 27 colorm=getfieldvalue(options,'colormap','jet'); 28 eval(['color=' colorm '(numcurves);']); 30 29 31 %resolution 32 if exist(options,'resolution'), 33 resolution=getfieldvalue(options,'resolution'); 34 else %Default resolution 35 resolution=[1000 10*md.numlayers]; 36 disp(['plot_section warning: no resolution specified, use default resolution: [horizontal_resolution vertical_resolution]=[' num2str(resolution) ']']); 37 end 30 %Loop over number of curves 31 for i=1:numcurves, 38 32 39 %Compute section value 40 if datatype==3, 41 [elements,x,y,z,s,data_s1]=SectionValues(md,data(:,1),getfieldvalue(options,'sectionvalue'),resolution); 42 [elements,x,y,z,s,data_s2]=SectionValues(md,data(:,2),getfieldvalue(options,'sectionvalue'),resolution); 43 else 44 [elements,x,y,z,s,data_s]=SectionValues(md,data,getfieldvalue(options,'sectionvalue'),resolution); 45 end 33 [datai datatype]=processdata(md,data(:,i),options); 46 34 47 %2D 48 if is2d 49 50 %Show Section if requested by user 51 if exist(options,'showsection') 52 53 %compute number of labels 54 numlabels=min(getfieldvalue(options,'showsection'),length(s)); 55 shift=fix(length(s)/numlabels); 56 57 %plot labels on current graph 58 hold on 59 text(s(1),data_s(1),'1','backgroundcolor',[0.8 0.9 0.8]) 60 for i=2:numlabels-1 61 text(s(1+(i-1)*shift),data_s(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8]) 62 end 63 text(s(end),data_s(end),'end','backgroundcolor',[0.8 0.9 0.8]) 64 65 %plot section only with labels 66 subplot(width,width,index2) 67 plot_unit(x_m,y_m,z_m,elements_m,data,is2d,datatype,options) 68 hold on 69 text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8]) 70 for i=2:numlabels-1 71 text(x(1+(i-1)*shift),y(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8]) 72 end 73 text(x(end),y(end),'end','backgroundcolor',[0.8 0.9 0.8]) 74 plot(x,y,'-r') 75 axis([min(md.x)-1 max(md.x)+1 min(md.y)-1 max(md.y)+1]) 76 view(2) 35 %replug x and y onto model so that SectionValue treats the problem correctly 36 if exist(options,'layer') 37 md.x=md.x2d; md.y=md.y2d; md.elements=md.elements2d; md.dim=2; 77 38 end 78 39 79 % plot section value80 subplot(width,width,index1)81 if datatype==3,82 plot(s,data_s1,s,data_s2);83 else84 plot(s,data_s)40 %resolution 41 if exist(options,'resolution'), 42 resolution=getfieldvalue(options,'resolution'); 43 else %Default resolution 44 resolution=[1000 10*md.numlayers]; 45 disp(['plot_section warning: no resolution specified, use default resolution: [horizontal_resolution vertical_resolution]=[' num2str(resolution) ']']); 85 46 end 86 47 87 %3D 88 else 89 %plot section value 90 % if user requested view2: 2d plot with curvilinear coordinate91 if (getfieldvalue(options,'view',3)==2 )48 %Compute section value 49 [elements,x,y,z,s,data_s]=SectionValues(md,datai,getfieldvalue(options,'sectionvalue'),resolution); 50 51 %2D 52 if is2d 92 53 93 54 %Show Section if requested by user … … 100 61 %plot labels on current graph 101 62 hold on 102 text(s(1), z(1),'1','backgroundcolor',[0.8 0.9 0.8])63 text(s(1),data_s(1),'1','backgroundcolor',[0.8 0.9 0.8]) 103 64 for i=2:numlabels-1 104 text(s(1+(i-1)*shift), z(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8])65 text(s(1+(i-1)*shift),data_s(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8]) 105 66 end 106 text(s(end), z(end),'end','backgroundcolor',[0.8 0.9 0.8])67 text(s(end),data_s(end),'end','backgroundcolor',[0.8 0.9 0.8]) 107 68 108 69 %plot section only with labels 109 70 subplot(width,width,index2) 110 plot_unit(x_m,y_m,z_m,elements_m,data ,is2d,datatype,options)71 plot_unit(x_m,y_m,z_m,elements_m,data(:,i),is2d,datatype,options) 111 72 hold on 112 73 text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8]) … … 120 81 end 121 82 83 %plot section value 84 hold on; 122 85 subplot(width,width,index1) 123 A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4); 124 patch( 'Faces', [A B C D], 'Vertices', [s z zeros(length(s),1)],'FaceVertexCData',data_s,'FaceColor','interp','EdgeColor','none'); 86 plot(s,data_s,'color',color(i,:)) 125 87 88 %3D 126 89 else 90 %plot section value 91 %if user requested view2: 2d plot with curvilinear coordinate 92 if (getfieldvalue(options,'view',3)==2 ) 127 93 128 %Show Section if requested by user129 if exist(options,'showsection')94 %Show Section if requested by user 95 if exist(options,'showsection') 130 96 131 %compute number of labels132 numlabels=min(getfieldvalue(options,'showsection'),length(s));133 shift=fix(length(x)/numlabels);97 %compute number of labels 98 numlabels=min(getfieldvalue(options,'showsection'),length(s)); 99 shift=fix(length(s)/numlabels); 134 100 135 %plot labels on current graph 136 hold on 137 text(x(1),y(1),z(1),'1','backgroundcolor',[0.8 0.9 0.8]) 138 for i=2:numlabels-1 139 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]) 101 %plot labels on current graph 102 hold on 103 text(s(1),z(1),'1','backgroundcolor',[0.8 0.9 0.8]) 104 for i=2:numlabels-1 105 text(s(1+(i-1)*shift),z(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8]) 106 end 107 text(s(end),z(end),'end','backgroundcolor',[0.8 0.9 0.8]) 108 109 %plot section only with labels 110 subplot(width,width,index2) 111 plot_unit(x_m,y_m,z_m,elements_m,data(:,i),is2d,datatype,options) 112 hold on 113 text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8]) 114 for i=2:numlabels-1 115 text(x(1+(i-1)*shift),y(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8]) 116 end 117 text(x(end),y(end),'end','backgroundcolor',[0.8 0.9 0.8]) 118 plot(x,y,'-r') 119 axis([min(md.x)-1 max(md.x)+1 min(md.y)-1 max(md.y)+1]) 120 view(2) 140 121 end 141 text(x(end),y(end),z(end),'end','backgroundcolor',[0.8 0.9 0.8])142 122 143 %plot section only with labels 144 subplot(width,width,index2) 145 plot_unit(x_m,y_m,z_m,elements_m,data,is2d,datatype,options) 146 hold on 147 text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8]) 148 for i=2:numlabels-1 149 text(x(1+(i-1)*shift),y(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8]) 123 subplot(width,width,index1) 124 A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4); 125 patch( 'Faces', [A B C D], 'Vertices', [s z zeros(length(s),1)],'FaceVertexCData',data_s,'FaceColor','interp','EdgeColor','none'); 126 127 else 128 129 %Show Section if requested by user 130 if exist(options,'showsection') 131 132 %compute number of labels 133 numlabels=min(getfieldvalue(options,'showsection'),length(s)); 134 shift=fix(length(x)/numlabels); 135 136 %plot labels on current graph 137 hold on 138 text(x(1),y(1),z(1),'1','backgroundcolor',[0.8 0.9 0.8]) 139 for i=2:numlabels-1 140 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]) 141 end 142 text(x(end),y(end),z(end),'end','backgroundcolor',[0.8 0.9 0.8]) 143 144 %plot section only with labels 145 subplot(width,width,index2) 146 plot_unit(x_m,y_m,z_m,elements_m,data,is2d,datatype,options) 147 hold on 148 text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8]) 149 for i=2:numlabels-1 150 text(x(1+(i-1)*shift),y(1+(i-1)*shift),num2str(i),'backgroundcolor',[0.8 0.9 0.8]) 151 end 152 text(x(end),y(end),'end','backgroundcolor',[0.8 0.9 0.8]) 153 plot(x,y,'-r') 154 axis([min(md.x)-1 max(md.x)+1 min(md.y)-1 max(md.y)+1]) 155 view(2) 150 156 end 151 text(x(end),y(end),'end','backgroundcolor',[0.8 0.9 0.8]) 152 plot(x,y,'-r') 153 axis([min(md.x)-1 max(md.x)+1 min(md.y)-1 max(md.y)+1]) 154 view(2) 157 158 subplot(width,width,index1) 159 A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4); 160 patch( 'Faces', [A B C D], 'Vertices', [x y z],'FaceVertexCData',data_s,'FaceColor','interp','EdgeColor','none'); 161 view(3) 162 155 163 end 156 157 subplot(width,width,index1)158 A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4);159 patch( 'Faces', [A B C D], 'Vertices', [x y z],'FaceVertexCData',data_s,'FaceColor','interp','EdgeColor','none');160 view(3)161 162 164 end 163 165 end
Note:
See TracChangeset
for help on using the changeset viewer.