Prev: set GCA and datetick problem
Next: Kalman Filter
From: Matthew on 20 Jan 2010 17:33 I plot multiple data series and use plotyy to graph two traces with same response but different magnitude. plot(A(:,1),A(:,2),'r:'); hold on; plotyy(A(:,1),A(:,3),A(:,1),A(:,4),'plot'); Now I want to look at many of these graphs and be sure all the axis are set the same. I follow the Solution ID: 1-50PK64 "Why do I not get any YTick marks ...." and use ha=findobj(gcf,'type','axes'); set(ha(1),'ylim',[0 60],'ytick',[20 40]); set(ha(2),'ylim',[-5e-5 10e-5]); However I get the error "Index exceeds matrix dimensions" and see ha is empty. I've also tried to use [AX, H1,H2] = plotyy(...) but cannot adjust a y-axis using axis([...]) without erasing the other axis. Also tried to use set(get() 'PropertyName') but cannot change the y limits correctly. What is the best way to use plot & plotyy then set both axis?
From: Paul Mennen on 21 Jan 2010 07:48 "Matthew " wrote > plot(A(:,1),A(:,2),'r:'); hold on; > plotyy(A(:,1),A(:,3),A(:,1),A(:,4),'plot'); > ha=findobj(gcf,'type','axes'); > However I get the error "Index exceeds matrix dimensions" and see ha is empty. That's strange. When I do that I find that ha is a 2 by 1 matrix containing the axis handles. I'm not sure why you get ha empty, but you might want to try the code below which should work: plot(A(:,1),A(:,2),'r:'); hold on; ha = plotyy(A(:,1),A(:,3),A(:,1),A(:,4),'plot'); set(ha(1),'ylim',[0 60],'ytick',[20 40]); set(ha(2),'ylim',[-5e-5 10e-5]); The other approach is to use plt.m (from the FEX) which is far easier when trying to put more than two lines on a single plot, especially when more than one axis is involved. For instance the above code could be replaced by the much more concise: plt(A(:,1),A(:,2:4),'ylim',{[0 60] [-5e-5 10e-5]},'+ytick',[20 40]); That would be optimized for data exploration (which includes cursors and other controls). If you wanted to optimize for publication instead, you would probably want to insert the following parameters into the above plt call: ,COLORdef',0,'Options','-All NoCursor' The COLORdef parameter would switch to the traditional Matlab plot colors which probably would be better for publication copy and the Options parameter removes the data exploration objects that might be considered clutter for a plot created just for the hard copy. Read the plt documentation (plt.chm) for more details. ~Paul
|
Pages: 1 Prev: set GCA and datetick problem Next: Kalman Filter |