How to created plot with three lines
조회 수: 12 (최근 30일)
이전 댓글 표시
I need to create a plot with three lines displayed on a single plot. I understand how to make three plots with the correct data but I need them on the same plot.
This is the format we use in my class to do so.
figure subplot(1,2,1) title () xlabel() ylabel()
This creates multiple plots. I know there is a way to make only a single plot but I cannot figure it out. Also, is there a way for me to enter a textbox that I can put an analysis of the plot in my figure?
댓글 수: 0
답변 (1개)
Star Strider
2015년 2월 15일
I would use the hold function to put all the plots on the same axis. The other function you want is legend:
x = linspace(-5, 5);
y1=x.^2;
y2=-5*x+2 ;
y3=4*ones(size(x));
figure(1)
plot(x, y1)
hold on
plot(x, y2)
plot(x, y3)
hold off
grid
legend('y_1', 'y_2', 'y_3', 'Location', 'SW')
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!