Filter löschen
Filter löschen

Why are the zoom callbacks of my figure not restored when I save and reopen my figure in MATLAB 7.8 (R2009a)?

1 Ansicht (letzte 30 Tage)
When I run the following code:
f = figure;
plot(1:10)
z1 = zoom(gcf);
set(z1,'ActionPostCallback','TMWtest')
saveas(f,'TMW_example_fig','fig')
close all
drawnow
open('TMW_example_fig.fig')
z2 = zoom(gcf);
get(z2,'ActionPostCallback')
The GET command returns the following:
ans =
[]
Why is the zoom callback not saved?

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 17 Aug. 2009
The ability to save zoom callbacks as part of the figure file is not available in MATLAB.
To work around this issue, you can use the "CreateFcn" callback (which is saved by the figure). We can use this callback to create the zoom callback automatically every time the figure is created.
Consider the following code:
f = figure;
plot(1:10)
set(f,'CreateFcn','z = zoom(gcf);set(z,''ActionPostCallback'',''TMWtest'')')
This code will automatically set the zoom callback "ActionPostCallback" to call "TMWtest.m", and this will happen every time the figure is opened.

Weitere Antworten (2)

Charles
Charles am 26 Aug. 2015
Thank you, this helps even on version 2015a. It puzzles me why the zoom callbacks are not saved with the figure while the datatip callbacks are. But, this does resolve the issue for me.

Charles
Charles am 26 Aug. 2015
Thank you, this helps even on version 2015a. It puzzles me why the zoom callbacks are not saved with the figure while the datatip callbacks are. But, this does resolve the issue for me.

Kategorien

Mehr zu Graphics Object Properties finden Sie in Help Center und File Exchange

Produkte


Version

R2009a

Community Treasure Hunt

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

Start Hunting!

Translated by