Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: None  |  size: 0.69 KB  |  hits: 27  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. MATLAB: legend for plotyy with multiple data sets
  2. [m,n]=size(data1); %data1 - m x 3 matrix with data for first sample.
  3. [ax,h1,h2]=plotyy([data1(1:m,1)],[data1(1:m,2)],[data1(1:m,1)],[data1(1:m,3)]);
  4.   %plots 1st sample data
  5.  
  6. set(h1,'linestyle','o')
  7. set(h2,'linestyle','o')
  8. c1=get(h1,'color);c2=get(h2,'color'); %store colors
  9.  
  10. line('parent',ax(1),'xdata','[data2(1:m,1)],'ydata',[data2(1:m,2)],...
  11.      'color',c1,'linestyle','s') %plots 2nd sample hardness
  12. line('parent',ax(2),'xdata','[data2(1:m,1)],'ydata',[data2(1:m,3)],...
  13.      'color',c2,'linestyle','s') %plots 2nd sample young's modulus
  14.        
  15. figure
  16. hold all
  17. for i=1:3
  18.     h(i) = plot([i i])
  19. end
  20. ylim([0 4])
  21.  
  22. legend([h([1 3])], {'aa', 'cc'})