Does anybody know how to include a legend in a figure of three functions with different colours or patterns?
Show older comments
Hi, I am plotting three functions at the same time in order to compare them and I would like to include a legend in this graphic, to represent the color and correspondet name of each function. Does anybody know how to do it?
plot(t,x1,'r'); hold on; plot(t,x2,b--o'); hold on plot(t,x3,g--');
Thank you!!!
title('Comparison'); xlabel('Time'); ylabel('f(t)');
subplot(132); plot(t1,x_rec_vel(:,2),'r'); hold on; plot(t1,Y(1:end-1,5),'b--o'); title('Velocity Mass 2'); xlabel('Time'); ylabel('v(t)');
subplot(133); plot(t1,x_rec_vel(:,3),'r'); hold on; plot(t1,Y(1:end-1,6),'b--o'); title('Velocity Mass 3'); xlabel('Time'); ylabel('v(t)');
Accepted Answer
More Answers (0)
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!