3D plot view changing in loop

I'm using a subplot to plot 6 3D figures using a loop. I set view(3) in my code and this works for the first figure but as the other figures come, they all tend to look more 2-D. This doesn't happen if I use a function to call all 6 individually but that isn't possible for my code. Another thing is that the figures all look as they should if I maximise the plot window.
function plot_fig123(n,X,Y,header)
load('terrain.mat')
subplot(2,3,n)
h = interp2(x_terrain,y_terrain,h_terrain,X,Y);
hold on;
plot3(X,Y,h,'ko','MarkerFaceColor','k','MarkerEdgeColor','k','MarkerSize',1);
plot3(X(end),Y(end),h(end),'ro',MarkerFaceColor='r')
surf(x_terrain, y_terrain, h_terrain);
colormap('jet'); shading interp;
title(header)
grid on; xlabel('x (m)'); ylabel('y (m)'); zlabel('z (m)');
view(3);
set(gca, 'LineWidth', 2, 'FontSize', 10, ...
'Xtick',-150:50:150, 'Ytick', -150:50:100, 'Ztick',-200:50:0)
end

6 件のコメント

VBBV
VBBV 2022 年 5 月 31 日
subplot(3,2,n) % chage the layout of subplot
view([90 0]);%try with view angle or previous value view(3)
AGASTHYA VALLURI
AGASTHYA VALLURI 2022 年 5 月 31 日
This is for a assignment so I cannot change the layout of the subplot as its required. View([90 0]) doesn't give me the right view either
AndresVar
AndresVar 2022 年 5 月 31 日
@AGASTHYA VALLURI does it look normal if you just make the figure bigger?
AGASTHYA VALLURI
AGASTHYA VALLURI 2022 年 5 月 31 日
Nope there was no effect, I set the default figure size as fullscreen and maximum but it still behaves the same way. But becomes the desirable output if I close and reopen the window
Arun
Arun 2023 年 10 月 12 日
編集済み: Arun 2023 年 10 月 12 日
try:
view(ax1,3); title(ax1,'view(0,90)');
Anton Kogios
Anton Kogios 2023 年 10 月 14 日
Can you please provide your terrain.mat file? And the code that calls your function too if possible. It's hard for people to help if we can't run your code ourselves...

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeAxes Appearance についてさらに検索

製品

リリース

R2022a

質問済み:

2022 年 5 月 31 日

コメント済み:

2023 年 10 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by