loluengo

ylabel centrado

May 25th, 2011
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.82 KB | None | 0 0
  1. pos_factor = 0.5;
  2.  
  3. clf
  4. f1= subplot( 2,1,1);
  5. plot(x,sin(x));
  6. f2= subplot( 2,1,2);
  7. plot(x,cos(x),'r');
  8. p1 = get(f1,'position');
  9. p2 = get(f2,'position');
  10. l2 = ylabel('lalala');
  11. l2p = get(l2,'position'); % posicion de ylabel en coords axis2
  12.  
  13. yM1 = p1(2)+p1(4);  % lim sup de f1 en coordenadas de figure
  14. yM2 = p2(2)+p2(4);  % lim sup de f2 en coordenadas de figure
  15. ym2 = p2(2);        % lim inf de f2 en coordenadas de figure
  16. axis2 = axis(f2);
  17.  
  18. %transformacion de coordenadas de axis2 a coordenadas de figure
  19. m = (yM2-ym2)/(axis2(4)-axis2(3));
  20. n = ym2 - m*axis2(3);
  21.  
  22. y02 = m*0+n; %posicion del y=cero de axis2 en figure
  23. yM1_2 = (yM1-n)/m; %posicion del tope sup de axis1 en coord axis2
  24. ym2_2 = axis2(3); % posicion del tope inf de axis2 en coord axis2
  25.  
  26. l2p(2) = (yM1_2-ym2_2)*pos_factor+ym2_2;
  27. set(l2,'position',l2p)
Advertisement
Add Comment
Please, Sign In to add comment