Changeset 5832


Ignore:
Timestamp:
09/15/10 16:31:17 (15 years ago)
Author:
seroussi
Message:

changed plot_section to create as many section as wanted

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/classes/public/plot/plot_section.m

    r4330 r5832  
    2020end
    2121
    22 %process data and model
     22%process model
    2323[x_m y_m z_m elements_m is2d]=processmesh(md,[],options);
    24 [data datatype]=processdata(md,data,options);
    2524
    26 %replug x and y onto model so that SectionValue treats the problem correctly
    27 if exist(options,'layer')
    28         md.x=md.x2d; md.y=md.y2d; md.elements=md.elements2d; md.dim=2;
    29 end
     25%Get number of curves and generate random colors
     26numcurves=size(data,2);
     27colorm=getfieldvalue(options,'colormap','jet');
     28eval(['color=' colorm '(numcurves);']);
    3029
    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
     31for i=1:numcurves,
    3832
    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);
    4634
    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;
    7738        end
    7839
    79         %plot section value
    80         subplot(width,width,index1)
    81         if datatype==3,
    82                 plot(s,data_s1,s,data_s2);
    83         else
    84                 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)  ']']);
    8546        end
    8647
    87 %3D
    88 else
    89         %plot section value
    90         %if user requested view2: 2d plot with curvilinear coordinate
    91         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
    9253
    9354                %Show Section if requested by user
     
    10061                        %plot labels on current graph
    10162                        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])
    10364                        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])
    10566                        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])
    10768
    10869                        %plot section only with labels
    10970                        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)
    11172                        hold on
    11273                        text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8])
     
    12081                end
    12182
     83                %plot section value
     84                hold on;
    12285                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,:))
    12587
     88                %3D
    12689        else
     90                %plot section value
     91                %if user requested view2: 2d plot with curvilinear coordinate
     92                if (getfieldvalue(options,'view',3)==2 )
    12793
    128                 %Show Section if requested by user
    129                 if exist(options,'showsection')
     94                        %Show Section if requested by user
     95                        if exist(options,'showsection')
    13096
    131                         %compute number of labels
    132                         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);
    134100
    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)
    140121                        end
    141                         text(x(end),y(end),z(end),'end','backgroundcolor',[0.8 0.9 0.8])
    142122
    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)
    150156                        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
    155163                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 
    162164        end
    163165end
Note: See TracChangeset for help on using the changeset viewer.