tags:

views:

47

answers:

1

I want to clear MATLAB's global CurrentFigure property, because I need a plot that I make to not be overwritten if a careless user uses plot without opening a new figure. I tried

set(0, 'CurrentFigure', []);

But it doesn't seem to work. Is this impossible?

+4  A: 

No, this doesn't work.

What does work is set(myFigureHandle,'HandleVisibility','off'). This way, the figure with the handle myFigureHandle will not become the current figure anymore.

To be really safe, you may want to set the axes' handle visibility to 'off', which will hide them from gca. In order to plot into these axes, you'll have to use plot(myAxesHandle,...), though, i.e. you have to explicitly point to the axes if you want to plot there.

Jonas

related questions