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!