MATLAB Answers

Good day. May I kindly ask anyone to look at the below script and associated Figure and advise on 1). How to manipulate the "Legend" so it doesnt Interfere/hide the time series. 2). Manage the colors of "time series" so they match thier "trend lines"

2 views (last 30 days)
MattyK
MattyK on 5 Feb 2016
Commented: MattyK on 8 Feb 2016
figure clf plot(YEARS,S1(2:28,:),'linewidth',2.5) hold on plot(YEARS,S2(1:27,:),'r--','linewidth',2.5) hold on plot(YEARS,S1_trend(2:28,:),'linewidth',2) hold on plot(YEARS,S2_trend(1:27,:),'r--','linewidth',2) axis([1983 2009 -5 5]) h = legend('Ser1', 'Ser2','Ser1-trend','Ser2-trend')

Accepted Answer

Ingrid
Ingrid on 5 Feb 2016
please use the documentation of the plot function to see how you can solve this
doc plot
but this is how you can do it
figure
clf
plot(YEARS,S1(2:28,:),'k''linewidth',2.5)
hold on
plot(YEARS,S2(1:27,:),'r','linewidth',2.5)
plot(YEARS,S1_trend(2:28,:),'k--','linewidth',2)
plot(YEARS,S2_trend(1:27,:),'r--','linewidth',2)
axis([1983 2009 -5 5])
h = legend('Ser1', 'Ser2','Ser1-trend','Ser2-trend')
set(h,'Location','EastOutside')
% chose the option that suits you best, for an overview type " doc legend" in the command window
  5 Comments

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by