Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. *Plot
  2. *Add legend
  3. *Add guidelines
  4.  
  5. %**** Optional guidelines
  6. figure(1)
  7. plot([2 2],[0,1],'k--'); hold on
  8.  
  9. %**** DATA
  10. N = 4;
  11. y=rand(5,N);
  12. x=1:1:5;
  13. for plotLoop=1:N;
  14. %* Plot
  15. figure(1)
  16. plot(x,y(plotLoop,:));
  17. hold on
  18. end
  19.  
  20. %*****LEGEND
  21. hLegend = legend(LegTxt,...
  22. 'interpreter','latex',...
  23. 'location','eastoutside')
  24.  
  25. %# plot something that shouldn't show up as legend
  26. handleWithoutLegend = plot(something);
  27.  
  28. %# modify the LegendInformation of the Annotation-Property of the graphical object
  29. set(get(get(handleWithoutLegend,'Annotation'),'LegendInformation'),...
  30. 'IconDisplayStyle','off');
  31.  
  32. %# toggle legend on and off at will, and never see the something-object appear
  33.  
  34. %**** Optional guidelines for periodicity
  35. figure(1)
  36. plot([2 2],[0,1],'k--'); hold on
  37.  
  38. %**** DATA
  39. N = 4;
  40. y=rand(5,N);
  41. x=1:1:5;
  42.  
  43. for plotLoop=1:N;
  44. LegTxt{plotLoop} = num2str(plotLoop);
  45. %* Plot
  46. figure(1)
  47.  
  48. % if statement to construct a handle for the legend later
  49. if plotLoop==1
  50. htot=plot(x,y(plotLoop,:));
  51. else
  52. h=plot(x,y(plotLoop,:));
  53. % Append this info to the figure handle
  54. htot= [htot, h];
  55. end
  56. hold on
  57.  
  58. end
  59.  
  60. %*****LEGEND
  61. hLegend = legend(htot,LegTxt,...
  62. 'interpreter','latex','FontSize',16,...
  63. 'location','eastoutside')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement