Search code examples
matlabmatlab-figureaxes

How to make these axis expressions explicit by Matlab axes?


Diff conditions: how to change the axis expressions to axes; implicit handling of figure axis cause unstable conditions etc graphs are plotted in wrong figures, ...
The function axis is a shorthand for simplified modification

The axis (not axes) function provides simplified access to commonly used properties that control the scaling and appearance of axes.

Code which is unstable

hFig2=figure(hFig2); 
hax2=axes(hFig2); 
plot(u); 
axis xy;
axis([0 (size(u,1)/1 - 0) min(u) max(u)]); 
axis off; 

Pseudocode to stabilise it but wrong syntax

hFig2=figure(hFig2); 
hax2=axes(hFig2); 
plot(u, hFig2); 
axis('xy', hFig2);
axis([0 (size(u,1)/1 - 0) min(u) max(u)], hFig2); 
axis('off', hFig2); 
  • Error

    Error using message
    In 'MATLAB:axis:UnknownOption', data type supplied is incorrect for parameter {1}.
    
    Error in axis (line 204)
                    error(message('MATLAB:axis:UnknownOption', cur_arg));
    
    Error in code_1s (line 563)
        axis('xy', hFig2);
    

Matlab: 2016a
OS: Debian 8.5
Hardware: Asus Zenbook UX303UA
Documentation: axis, axes


Solution

  • axis operates on a specific axes (or an array of axes objects) not a figure. If you want it to be stable and apply axis to a specific axes, just pass that axes handle as the first input to axis

    axis(hax2, 'xy')
    axis(hax2, [0 (size(u,1)/1 - 0) min(u) max(u)])
    axis(hax2, 'off')