Same aspect ratio for the z-axis in a surface plot

조회 수: 5 (최근 30일)
Alexandra Roxana 2023년 6월 8일
편집: Alexandra Roxana 2023년 6월 10일
I have a surface plot
and the x-axis and y-axis have the same ratio. I wish for the z-axis to have the same ratio. I have used
daspect ([1 1 1])
but it turns into a 2D plot.
I have used this code for the same aspect ratio for the x-axis and y-axis.
h=get(gca,'DataAspectRatio');
if h(3)==1
set(gca,'DataAspectRatio',[1 1 1/max(h(1:2))])
else
set(gca,'DataAspectRatio',[1 1 h(3)])
end
댓글 수: 3이전 댓글 1개 표시이전 댓글 1개 숨기기
Mathieu NOE 2023년 6월 9일
maybe you get a 2D plot because the range of your z axis is 1000 times smaller than the range of x, y axes
Alexandra Roxana 2023년 6월 10일
@Mathieu NOE It still should be a solution for this.

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

채택된 답변

Simon Chan 2023년 6월 10일
As mentioned by Mathieu NOE in the comment section, your z-axis data is 1000 times smaller than the range of x and y-axes data. Hence the ratio between them should be rescale accordingly.
Check whether this is what you want or not.
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
surface(X/5+1,Y/3.5,Z*1e-3) % Just make sure the range of the demo data is close to your data
view(3)
daspect ([1 1 1e-3]);
댓글 수: 10이전 댓글 8개 표시이전 댓글 8개 숨기기
Simon Chan 2023년 6월 10일
Glad to see you come up with a new idea. Just curious your data along z-axis is also in time unit?
Alexandra Roxana 2023년 6월 10일
편집: Alexandra Roxana 2023년 6월 10일
No, it is the solution so it doesn't work. I'm thinking at how I could plot this if for instance, I would measure on a piece of paper with a ruler, this is how I would like for it to look. The grid should be very detailed. This is how a part of the solution looks like:

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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by