Disappear of z coordinate when plotting 3D
조회 수: 16 (최근 30일)
이전 댓글 표시
Hi,
When I use figure and hold on with a for loop to plot a 3D plot, the z coordinate component always disappears which means the plot becomes 2D. Could anyone help the solve the issue? Thanks in advance. The folloing is the general code.
figure();
for index=1:max_val_1
other_code_here.....
for i=1:max_val_2
other_code_here.....
plot3(edge(i,1),edge(i,2),edge(i,3), 'o');
xlabel('x')
xlim([min max])
ylabel('y')
ylim([min max])
zlabel('z')
zlim([min max])
end
grid on
hold on
end
댓글 수: 0
답변 (2개)
the cyclist
2019년 11월 10일
view(15,15)
after the plot is made.
I've seen a couple questions like this lately, so I'm wondering if there is some kind of bug with MATLAB defaulting to the "2-D" view (i.e. directly from "above", along the z-axis) when it should not be. I haven't been able to pin it down exactly enough for a bug report, though.
댓글 수: 2
the cyclist
2019년 11월 10일
I think you probably want the hold on statement immediately after the figure command (assuming your goal is to show every plot in that figure window). See the documentation for hold for the details.
Image Analyst
2019년 11월 10일
Since you're plotting only a single point with each call to
plot3(edge(i,1),edge(i,2),edge(i,3), 'o');
you should place "hold on" inside that inner loop. And it should plot all max_val_2 points. Note that there is no reference to "index" inside your "i" loop so you should not expect anything different unless the badly-named "edge" vector changes within the outer "index" loop. By the way, edge(), min(), and max() are the names of a built-in functions so you don't want to use those as the names of your variable.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!