Changeset 8001


Ignore:
Timestamp:
04/21/11 07:34:15 (14 years ago)
Author:
Mathieu Morlighem
Message:

Moved inset to applyoptions (more general)
Added 'offsetaxispos' option to get more space
Posting for gridded plot has a default value
Clipped text so that it does not appear if outside of the box

Location:
issm/trunk/src/m/model/plot
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/model/plot/applyoptions.m

    r7946 r8001  
    284284                textpositioni=textposition{i};
    285285                textrotationi=textrotation{i};
    286                 text(textpositioni(1),textpositioni(2),textstringi,'FontSize',textsizei,'FontWeight',textweighti,'Color',textcolori,'Rotation',textrotationi);
     286                h=text(textpositioni(1),textpositioni(2),textstringi,'FontSize',textsizei,'FontWeight',textweighti,'Color',textcolori,'Rotation',textrotationi);
     287                set(h,'Clipping','on'); %prevent text from appearing outside of the box
    287288        end
    288289end
     
    326327if exist(options,'ytick'),
    327328        set(gca,'ytick',getfieldvalue(options,'ytick'));
     329end
     330
     331%Axis positions
     332if exist(options,'offsetaxispos'),
     333        offset=getfieldvalue(options,'offsetaxispos');
     334        P=get(gca,'pos');
     335        P(1)=P(1)+offset(1);
     336        P(2)=P(2)+offset(2);
     337        P(3)=P(3)+offset(3);
     338        P(3)=P(4)+offset(4);
     339        set(gca,'pos',P);
    328340end
    329341
     
    339351                        set(gcf,'Position',[756    62   827   504]);
    340352                elseif strcmpi(figposition,'mathieu'),
    341                         set(gcf,'Position',[1 1 1580 1150]);
     353                        set(gcf,'Position',[300 1 1580 1150]);
    342354                elseif strcmpi(figposition,'fullscreen'),
    343355                        set(gcf,'Position',get(0,'ScreenSize'));
     
    378390%showregion
    379391if strcmpi(getfieldvalue(options,'showregion','off'),'on'),
     392        %Keep pointer of main axis
     393        maingca=gca;
    380394        %get inset relative position (x,y,width,height)
    381395        insetpos=getfieldvalue(options,'insetpos',[0.02 0.70 0.18 0.18]);
    382396        %get current plos position
    383         cplotpos=get(gca,'pos');
     397        cplotpos=get(maingca,'pos');
    384398        %compute inset position
    385399        PosInset=[cplotpos(1)+insetpos(1)*cplotpos(3),cplotpos(2)+insetpos(2)*cplotpos(4), insetpos(3)*cplotpos(3), insetpos(4)*cplotpos(4)];
     
    408422        patch( [mdx(1) mdx(2) mdx(2) mdx(1)],[mdy(1) mdy(1) mdy(2) mdy(2)],ones(4,1),'EdgeColor',[0 0 0],'FaceColor','r','FaceAlpha',0.5)
    409423        colorbar('off');
     424        %back to main gca
     425        set(gcf,'CurrentAxes',maingca)
    410426end
    411427
     
    434450        light('Position',[0 0.1 0.1],'Style','infinite');
    435451end
     452
     453%========================%
     454%OK VERY LAST STEP: INSET|
     455%========================%
     456if exist(options,'inset'),
     457
     458        %Keep pointer of main axis
     459        maingca=gca;
     460        %get inset relative position (x,y,width,height)
     461        insetpos=getfieldvalue(options,'insetpos',[0.56 0.55 0.35 0.35]);
     462        %get current plot position
     463        cplotpos=get(gca,'pos');
     464        %compute inset position
     465        PosInset=[cplotpos(1)+insetpos(1)*cplotpos(3),cplotpos(2)+insetpos(2)*cplotpos(4), insetpos(3)*cplotpos(3), insetpos(4)*cplotpos(4)];
     466        %show pos
     467        X1=getfieldvalue(options,'insetx',xlim);
     468        Y1=getfieldvalue(options,'insety',ylim);
     469        if strcmpi(getfieldvalue(options,'showinset','off'),'on')
     470                line(X1([1 2 2 1 1]),Y1([1 1 2 2 1]),zeros(1,5),'Color','k','LineWidth',2);
     471        end
     472
     473        %Get current figure
     474        ax1=gca;
     475
     476        %plot inset
     477        axes('pos',PosInset);
     478        copyobj(get(ax1,'children'),gca);
     479        patch('Faces',[1 2 3 4 1],'Vertices',[X1([1 2 2 1])' Y1([1 1 2 2])'],'FaceColor','None','EdgeColor','k','LineWidth',2);
     480
     481        %applay options
     482        options=removefield(options,'text',0);
     483        options=removefield(options,'inset',0);
     484        options=removefield(options,'offsetaxispos',0);
     485        options=removefield(options,'showregion',0);
     486        options=changefieldvalue(options,'colorbar',0);
     487        options=changefieldvalue(options,'latlon','off');
     488        options=changefieldvalue(options,'axis','equal off');
     489        options=changefieldvalue(options,'xlim',getfieldvalue(options,'insetx',xlim));
     490        options=changefieldvalue(options,'ylim',getfieldvalue(options,'insety',ylim));
     491        applyoptions(md,data,options);
     492
     493        %back to main gca
     494        set(gcf,'CurrentAxes',maingca)
     495end
  • issm/trunk/src/m/model/plot/plot_gridded.m

    r7942 r8001  
    99%process mesh and data
    1010[x y z elements is2d]=processmesh(md,[],options);
     11[data datatype]=processdata(md,data,options);
    1112
    1213%check is2d
     
    1819xlim=getfieldvalue(options,'xlim',[min(x) max(x)]);
    1920ylim=getfieldvalue(options,'ylim',[min(y) max(y)]);
    20 post=getfieldvalue(options,'posting',500);
     21post=getfieldvalue(options,'posting',diff(xlim)/1000);
    2122
    2223%Interpolating data on grid
     
    3435        data_max=max(data_grid(:));
    3536end
    36 white  =data_min - (data_max-data_min)/60;
     37white  =data_min - (data_max-data_min)/55;
    3738options=changefieldvalue(options,'caxis',[white data_max]);
    3839data_grid(isnan(data_grid))=white;
     
    4748%set(gca,'pos',P);
    4849
    49 %pcolor(xlim(1)+post/2:post:xlim(2)-post/2,ylim(1)+post/2:post:ylim(2)-post/2,data_grid);set(gca,'YDir','normal');
    5050%shading interp;
    5151h=imagesc(xlim,ylim,data_grid);set(gca,'YDir','normal');
  • issm/trunk/src/m/model/plot/plot_manager.m

    r7986 r8001  
    190190
    191191applyoptions(md,data2,options,h);
    192 
    193 %plot inset if requested
    194 if exist(options,'inset'),
    195 
    196         %get inset relative position (x,y,width,height)
    197         insetpos=getfieldvalue(options,'insetpos',[0.56 0.55 0.35 0.35]);
    198         %get current plos position
    199         cplotpos=get(gca,'pos');
    200         %compute inset position
    201         PosInset=[cplotpos(1)+insetpos(1)*cplotpos(3),cplotpos(2)+insetpos(2)*cplotpos(4), insetpos(3)*cplotpos(3), insetpos(4)*cplotpos(4)];
    202         %show pos
    203         X1=getfieldvalue(options,'insetx',[min(x) max(x)]);
    204         Y1=getfieldvalue(options,'insety',[min(y) max(y)]);
    205         if strcmpi(getfieldvalue(options,'showinset','off'),'on')
    206                 line(X1([1 2 2 1 1]),Y1([1 1 2 2 1]),zeros(1,5),'Color','k','LineWidth',2);
    207         end
    208 
    209         %plot inset
    210         axes('pos',PosInset);
    211         box('on')
    212         patch('Faces',[1 2 3 4 1],'Vertices',[X1([1 2 2 1])' Y1([1 1 2 2])' -10^10*ones(4,1)],'FaceColor','w','EdgeColor','k');
    213         hold on
    214         h=plot_unit(x,y,z,elements,data2,is2d,datatype,options);
    215 
    216         %applay options
    217         options=changefieldvalue(options,'colorbar',0);
    218         options=changefieldvalue(options,'text',{});
    219         options=changefieldvalue(options,'latlon','off');
    220         options=changefieldvalue(options,'axis','equal off');
    221         options=changefieldvalue(options,'xlim',getfieldvalue(options,'insetx',[min(x) max(x)]));
    222         options=changefieldvalue(options,'ylim',getfieldvalue(options,'insety',[min(y) max(y)]));
    223         applyoptions(md,data2,options);
    224 end
    225192
    226193%do ground overlay on kml plot_unit?
  • issm/trunk/src/m/model/plot/plot_unit.m

    r7651 r8001  
    99%edgecolor
    1010edgecolor=getfieldvalue(options,'edgecolor','none');
    11 %P=get(gca,'pos')
    12 %P(3)=P(3)+0.04;
    13 %P(1)=P(1)-0.02;
    14 %set(gca,'pos',P);
    1511
    1612switch datatype,
  • issm/trunk/src/m/model/plot/plotdoc.m

    r7874 r8001  
    140140disp('                  hmin,hmax and hnint are the minimum, maximum and number of intervals of the histogram (optional)');
    141141disp('       ''figposition'': position of figure: ''fullscreen'', ''halfright'', ''halfleft'', ''portrait'', ''landscape'',... (hardcoded in applyoptions.m)');
     142disp('       ''offsetaxispos'': offset of current axis position to get more space (ex: [-0.02 0  0.04 0])');
    142143disp('       ''hmin'': (numeric, minimum for histogram)');
    143144disp('       ''hmax'': (numeric, maximum for histogram)');
Note: See TracChangeset for help on using the changeset viewer.