Changeset 19204


Ignore:
Timestamp:
03/17/15 15:52:50 (10 years ago)
Author:
Mathieu Morlighem
Message:

BUG: fixed bug on some macs due to getframe that introduces an offset in the axis. Fix is to use 'nofigurecopy' option

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/exp/exptool.m

    r15333 r19204  
    1616%      - markersize (default=7)
    1717%      - markeredgecolor (default='r')
     18%      - nofigurecopy (default=0) do not copy current figure, this is needed on some plateform to avoid an offset in the figure
    1819%
    1920%   Usage:
     
    9899
    99100%get current figure
    100 if ~isempty(get(0,'children')),%if there is already a figure (return the number of opened figures)
    101         set(gcf,'Renderer','zbuffer'); %fixes a bug on Mac OS X (not needed in future Matlab version)
    102         P=get(gcf,'position');
    103         F=getframe(gca);
    104         F=F.cdata;
    105         %get current axis
    106         xlim=get(gca,'Xlim');
    107         ylim=get(gca,'Ylim');
    108         %recreate x_m and y_m
    109         x_m=linspace(xlim(1),xlim(2),size(F,2));
    110         y_m=linspace(ylim(2),ylim(1),size(F,1)); %getframe reverse axis...
    111         %plot the data in another figure
    112         figure; set(gcf,'position',P);
    113         imagesc(x_m,y_m,F); set(gca,'Ydir','normal');
    114         prevplot=1;
    115         prevplot2=1;
     101nofigurecopy=getfieldvalue(options,'nofigurecopy',1);
     102if ~nofigurecopy,
     103        if ~isempty(get(0,'children')),%if there is already a figure (return the number of opened figures)
     104                set(gcf,'Renderer','zbuffer'); %fixes a bug on Mac OS X (not needed in future Matlab version)
     105                P=get(gcf,'position');
     106                Fp=get(gca,'position');
     107                F=getframe(gca);
     108                F=F.cdata;
     109                %get current axis
     110                xlim=get(gca,'Xlim');
     111                ylim=get(gca,'Ylim');
     112                %recreate x_m and y_m
     113                x_m=linspace(xlim(1),xlim(2),size(F,2));
     114                y_m=linspace(ylim(2),ylim(1),size(F,1)); %getframe reverse axis...
     115                %plot the data in another figure
     116                figure; set(gcf,'position',P);
     117                imagesc(x_m,y_m,F); set(gca,'Ydir','normal','Position',Fp,'Xlim',xlim,'Ylim',ylim);
     118                prevplot=1;
     119                prevplot2=1;
     120        else
     121                figure
     122                prevplot=0;
     123                prevplot2=0;
     124        end
    116125else
    117         figure
    118         prevplot=0;
    119         prevplot2=0;
     126        g=get(gca,'children');
     127        L=length(g);
     128        prevplot=L;
     129        prevplot2=L;
    120130end
    121131
     
    348358
    349359%close window
    350 close;
     360if ~nofigurecopy,
     361        close;
     362end
Note: See TracChangeset for help on using the changeset viewer.