How can I get multiple plots on one graph, not overlapping?

조회 수: 51 (최근 30일)
Emily LaPrime
Emily LaPrime 2021년 9월 24일
댓글: Emily LaPrime 2021년 9월 24일
I need to plot 3 graphs on the same figure. I have attached two figures. In my current figure, they are all overlapping. The second figure (black and white) is what I need the plot to look like (it has to look exactly like this for the assignment). So I don't want subplots, but I do need some way to separate the plots so that you can see them all on the same plot, just not on top of each other. Could anybody help me with this, please?

채택된 답변

the cyclist
the cyclist 2021년 9월 24일
What an ugly and potentially confusing plotting style. Too bad you are being coerced into doing it that way.
One way to do this is to manually move the plots upward from each other by adding a fixed offset to them (the +2 and +4 you see in my code below), and then kludge the y-axis labels accordingly.
rng default
x = 1:100;
y_H = rand(1,100);
y_M = rand(1,100);
y_L = rand(1,100);
figure
hold on
plot(x,y_H + 4);
plot(x,y_M + 2);
plot(x,y_L);
set(gca,'YTick',0:0.5:5,'YTickLabel',[0 0.5 1 1.5 0 0.5 1 1.5 0 0.5 1])
  댓글 수: 1
Emily LaPrime
Emily LaPrime 2021년 9월 24일
Thank you so much! I had to do some messing around with the Property Editor also, but I was able to figure it out. Much appreciated!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by