필터 지우기
필터 지우기

How to edit a surf graph?

조회 수: 3 (최근 30일)
zephyr21
zephyr21 2016년 6월 21일
댓글: Chad Greene 2016년 6월 21일
I currently have the code
for n=1:N
surf(P_overtime(:,:,n));
axis tight
colormap
colorbar
drawnow
pause(.2)
end
The y- axis changes after P-overtime drops below certain values. How do set the limits of my y axis from 8000 to 3000. Also, how can I have colors coordinating to certain values as the number decrease?

채택된 답변

Chad Greene
Chad Greene 2016년 6월 21일
I'm not sure why colormap is in there--you can remove that line.
Set the y axis limits like this:
ylim([3000 8000])
Set the color axis limits in a similar way to make sure the colors change with the data like this:
caxis([150 575])
where I've used 150 and 575 as some arbitrary low and high values.
Try to do as little as possible inside the loop, because every time you call something in a loop, it eats up computational time. I suggest this rewrite:
h = surf(P_overtime(:,:,1));
axis tight
colorbar
ylim([3000 8000])
caxis([150 575])
for n = 2:N;
set(h,'cdata',P_overtime(:,:,n),'zdata',P_overtime(:,:,n))
drawnow
pause(.2)
end
  댓글 수: 2
Walter Roberson
Walter Roberson 2016년 6월 21일
You do not need both drawnow() and pause(): pause() automatically flushes the buffer.
Chad Greene
Chad Greene 2016년 6월 21일
Oh, good to know!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by