function [hax,hline]=PlotLineZoom(xx,yy,xx1,MyFillC); % Plot a time series with a zoom window % usage: % [hax,hline]=PlotLineZoom(xx,yy,xx1) % http://scriptdemo.blogspot.com % The whole time series hax(1)=axes('position',[0.13 0.13 0.77 0.72]); hline(1)=plot(xx,yy); xdiff05=0.5*max(diff(xx)); set(hline(1),'linewidth',2,'color','k','linestyle','-','marker','none'); set(hax(1),'tickdir','out','xminortick','on','yminortick','on','fontweight', ... 'bold','fontsize',14,'xlim',[xx(1)-xdiff05 xx(end)+xdiff05]); % zoomed region NX1=find(xx==xx1(1)); NX2=find(xx==xx1(end)); yy1=yy(NX1:NX2); MaxY=max(yy1); MinY=min(yy1); if ~ishold hold on; end if exist('MyFillC','var') hf=fill([xx1(1) xx1(end) xx1(end) xx1(1) xx1(1)],[MinY MinY MaxY MaxY MinY],MyFillC); set(hf,'linestyle','none','facealpha',0.6); else plot([xx1(1) xx1(end) xx1(end) xx1(1) xx1(1)],[MinY MinY MaxY MaxY MinY],'r','linewidth',2); end % zoom window hax(2)=axes('position',[0.5 0.2 0.3500 0.2000]); hline(2)=plot(xx1,yy1); set(hline(2),'linewidth',2,'color','r','linestyle','-','marker','o', ... 'markersize',6,'markerfacecolor','r','markeredgecolor','k'); set(hax(2),'color','none','tickdir','in','box','on','fontweight','bold', ... 'fontsize',10,'xtick',xx1,'xlim',[xx1(1) xx1(end)+0.2*xdiff05]); % figure properties set(gcf,'color','w'); |
Tuesday, February 16, 2010
Time series plot with a zoom window
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment