Open figure and work on that figure

151 Ansichten (letzte 30 Tage)
Shan  Chu
Shan Chu am 29 Sep. 2018
Kommentiert: Adam am 1 Okt. 2018
Dear all,
I would like to ask it is a way to work on a saved figure. For example, add more line plots and also change the axes. I have been trying but didn't succeed.
Here is the code that I made:
figure
hold on
openfig('x.fig')
plot(A);
ax = gca;
ax.XTick = [0 0.01 0.03 0.05]
Thanks
  4 Kommentare
Rik
Rik am 1 Okt. 2018
You will notice that the call to figure is not needed, as openfig already opens a new figure window for the loaded figure.
Adam
Adam am 1 Okt. 2018
You should use the
fig = openfig(...)
syntax too to get an explicit handle for your figure. Relying on your desired figure always being the one in focus can lead to some unexpected bugs.
Working with explicit handles is always better. Obviously in this case that is limited - I assume your figure only contains one axes, otherwise I have no idea which axes in the figure would be regarded as the current one, but if you do only have one axes:
hFig = openfig( ... );
hAxes = hFig.CurrentAxes;
will give you your explicit axes handle to work with as well as the figure handle, if required.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by