how to define an axis in other figure to plot in it

30 ビュー (過去 30 日間)
ali hadjer
ali hadjer 2015 年 11 月 3 日
コメント済み: Walter Roberson 2015 年 11 月 3 日
how to define an axes in other figure to plot in it WITH A CALLBACK OF PUSHBOUTON IN THE OTHER FIGURE NB:AXES2 IN FIGURE2 PUSH BUTON IN FIGURE ON

採用された回答

Adam
Adam 2015 年 11 月 3 日
figure; hAxes = gca;
plot( hAxes,... )
allows you to plot on a different axes and is recommended anyway (giving an explicit axes handle) rather than relying on whatever the current axes happens to be.

その他の回答 (1 件)

Jan
Jan 2015 年 11 月 3 日
You have to obtain the handle of the axes you want to draw in. You can get it either by e.g. findobj, when you define a unique Tag property for the concerned axes.
figure;
axes('Tag', 'IWantToDrawHere');
Code of the other GUI:
figure;
uicontrol('Style', 'PushButton', 'Callback', @buttonCallback);
function buttonCallback(ButtonH, EventData)
AxesH = findobj('Tag', 'IWantToDrawHere');
if length(AxesH) ~= 1
warning('Cannot find my axes?!');
return;
end
plot(1:10, rand(1, 10), 'Parent', AxesH);
A drawback of this method is the run-time: If you have many open figures with a lot of objects, searching all of them to find the tag is not fast. So it would be better to store the axes handle in the UserData or ApplicationData of the figure and search it there.
  2 件のコメント
ali hadjer
ali hadjer 2015 年 11 月 3 日
ITS NOT WORKER????? :( HOW I DO
Walter Roberson
Walter Roberson 2015 年 11 月 3 日
What error message do you get?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by