3D plot in appdesigner
78 ビュー (過去 30 日間)
古いコメントを表示
why do i get 2D plot instead of 3D
function startupFcn(app)
cla (app.UIAxes,'reset')
hold (app.UIAxes,'on')
Pi = [0,0,0];
Pii = [4,1,0];
Piii = [1,4,0];
Piv = [1,1,3];
Pv = [1,1,0];
pts0 = [Pi;Pii];
pts1 = [Pi;Piii];
pts2 = [Pii;Piii];
pts3 = [Piv;Pv];
plot3(app.UIAxes,pts0(:,1),pts0(:,2),pts0(:,3),'Color','b')
plot3(app.UIAxes,pts1(:,1),pts1(:,2),pts1(:,3),'Color','b')
plot3(app.UIAxes,pts2(:,1),pts2(:,2),pts2(:,3),'Color','b')
plot3(app.UIAxes,pts3(:,1),pts3(:,2),pts3(:,3),'Color','r')
xlabel(app.UIAxes,'length');
ylabel(app.UIAxes,'width');
zlabel(app.UIAxes,'height');
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/245050/image.png)
0 件のコメント
採用された回答
Hope Q
2019 年 10 月 25 日
Use the view command to set the perspective on the axes.
For example:
view(app.UIAxes,[-5 2 5])
3 件のコメント
Abdulrasheed Afolabi
2020 年 5 月 6 日
編集済み: Abdulrasheed Afolabi
2020 年 5 月 6 日
Thanks, it's a life saver.
その他の回答 (1 件)
Hope Q
2019 年 10 月 25 日
What version are you using?
I'm using R2019b Update 1 on 64-bit Windows.
I pasted your code into a new blank App with one UIaxes.
I added the line
view(app.UIAxes,[5 2 5])
as the last line in the startupFcn. The 3D plot was in the UIAxes as expected.
![3Dplot.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/245059/3Dplot.png)
参考
カテゴリ
Help Center および File Exchange で Develop Apps Using App Designer についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!