
How can I adjust the data aspect ratio in a plot with two y axes?
    5 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    John van Zalk
 il 8 Feb 2017
  
    
    
    
    
    Risposto: Chad Greene
      
      
 il 8 Feb 2017
            Hi all,
I am trying to create a Walter and Leith climate plot in Matlab. The scale of the right y axis needs to be double that of the left y axis and the numbers on the left axis should align with the numbers on the right axis. When I attempt to change the data aspect ratio Matlab returned: Warning: Only 'auto' DataAspectRatio is supported for axes with multiple coordinate systems. Are there any workarounds to this problem?
Cheers,
John

0 Commenti
Risposta accettata
  Chad Greene
      
      
 il 8 Feb 2017
        I'd set the limits of each axis individually, something like this:
% some data: 
t = 1:12; 
T = 20*sin(pi*t/12); 
P = 30*sin(pi*t/12)+5*randn(size(t))+30; 
% Plot the data
[ax,h1,h2]  = plotyy(t,T,t,P); 
% Set the axis limits of the T data: 
set(ax(1),'xlim',[1 12],...
   'ylim',[0 50],...
   'ytick',0:10:50,...
   'ycolor','r')
% Set the color of the T data line: 
set(h1,'color','r','linewidth',2)
% Set the P data color and axis limits: 
set(ax(2),'xlim',[1 12],...
   'ylim',[0 100],...
   'ytick',0:20:100,...
   'ycolor','b')
set(h2,'color','b','linewidth',2)
box off

0 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Calendar in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!