Is it possible to plot a plot() and area() on same axis

조회 수: 2 (최근 30일)
Vadim Kachan
Vadim Kachan 2019년 7월 17일
댓글: Star Strider 2019년 7월 17일
Hi,
I am doing data analysis and am trying to plot a data set of y over x with area() and then plot a line of moving avg of y over x with plot() on the same axis. currently it doesn't work. Meaning i get the second graph vs. both at the same time.
Has anyone come up with a solution for this?
y1 = B57(x,2);
Avg1 = movmean(y1,7)
area(PlotAX1,1:length(B57),y1);
area(PlotAX1,1:length(B57),Avg1)

채택된 답변

Star Strider
Star Strider 2019년 7월 17일
Use the hold function:
B57 = rand(1, 100); % Create ‘B57’
y1 = B57;
PlotAX1 = axes; % Create ‘PlotAX1’
Avg1 = movmean(y1,7);
area(PlotAX1,1:length(B57),y1);
hold on
area(PlotAX1,1:length(B57),Avg1)
hold off
  댓글 수: 2
Vadim Kachan
Vadim Kachan 2019년 7월 17일
That's perfect. For second plot i actually needed plot(). I plugged that in and it worked perfectly!
Star Strider
Star Strider 2019년 7월 17일
Great!

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by