Search code examples
matlabaxes

Deleting a created axes in Matlab


How do I remove an axes object from a figure in Matlab? I created one using

haxis = axes('position', [0.1 0.1 0.8 0.8]);

Now I want to remove it! (i.e. not just hide the lines - actually delete the object?)

I tried cla but that just removes objects drawn in the axes.

clf will do it but also removes all other axes, which I need to keep.


Solution

  • Fortunately, just saying what you want to do works:

    delete(haxis)
    

    I believe the same is true for other graphics handles.