MATLAB Answers

is it a bug?

2 views (last 30 days)
G A on 17 Jul 2019
Edited: G A on 17 Jul 2019
In the following code, if view(2) or view(0,90) is defined before axis() which is not auto, then a default 3D figure will be plotted instead of flat 2D image. If view(2) or view(0,90) is defined after axis(), then it works. However, view(360,90) works before as well as after non-auto axis().
%view(2), view(0,90) this does not work before axis() which is not auto
view(360,90), %this works before and after axis()
axis([X(1) X(end) Y(1) Y(end) min(min(Z)) max(max(Z))]),
%view(2), view(0,90) %this works after axis()
grid on


Sign in to comment.

Answers (1)

Nicolas B.
Nicolas B. on 17 Jul 2019
I have also experienced what you described. After investigation, even if it is not in the function documentation, the code of the function axis() resets the view of the plot to the default values. So no, it's not a bug, just an undocumented feature of the axis() function.
Therefore, I would recommend you to call axis() function before calling view().

  1 Comment

G A on 17 Jul 2019
Why then axis does not reset view() in the case of view(360,90) and in the case of 3D view with any other angles than (0,90)? For example view(45,20) will be not reset and it works OK before as well as after non-auto axis(). If you use axis auto, then also there will be no reset for view(2) or view(0,90) used before axis(). 'Call axis before view in those two particular cases' must be documented in Matlab - not left to find such behaviour by users after trial and error. Otherwise, I think, that is a bug.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by