필터 지우기
필터 지우기

Opening stored figures directly in GUI

조회 수: 4 (최근 30일)
Lipa
Lipa 2012년 7월 3일
댓글: Cheng, Nestic 2016년 3월 29일
I've stumbled upon this problem which I thought would be easy to solve, but my limited experience with Matlab forced me to seek for help.
I have a figure stored in a .fig file, and I have a GUI with an 'axes' object. I would like to open the stored figure file and display the figure in the axes of the GUI. What is the best way to achieve this?
Thank you very much for your help!

답변 (2개)

Sean de Wolski
Sean de Wolski 2012년 7월 3일
편집: Sean de Wolski 2012년 7월 3일
This is not possible. An axes cannot be a container for a figure. You could load the figure, take a snapshot of it ( getframe or print ) and then display this as an image in the axes but all functionality will be gone.
What are you trying to do? Perhaps we could help you come up with a nicer solution.
  댓글 수: 1
Lipa
Lipa 2012년 7월 4일
Thank you for your reply!
What I would like to do is the following: In one program, I create a surface plot which is then stored on disk as 'plot.fig'. Then, in another GUI program, I would like to bring up that stored figure for viewing with full functionality. It is straightforward to just open the figure in its own window using 'openfig', but I would much prefer if I could open it in some predefined space within the GUI (i.e. the "axes" object), and not in another window.
Any further ideas are most appreciated!

댓글을 달려면 로그인하십시오.


Kevin Claytor
Kevin Claytor 2012년 7월 3일
You could transfer the data over reasonably fast with something like;
% Example of transfering data from one figure to another
f1 = figure; % The figure we want to transfer to
h2 = subplot(3,3,4); % The axes we want to transfer to
od = open('untitled.fig'); % Load our saved figure
%get(get(x,'CurrentAxes'))
% This command displays all the options we can
% transfer over, for this example, I'll just transfer the data
datahandles = get(get(x,'CurrentAxes'),'Children');
for ii = 1:length(datahandles)
set(datahandles(ii),'Parent',h2);
end
% Close the other figure
close(od)
You'll have to tweak it to transfer other properties (title, labels, etc) over, but that should get you started.
  댓글 수: 4
Jan
Jan 2016년 3월 22일
@Cheng: As you found out, you cannot open a the contents of a fig file in an axes object. You can copy axes objects to axes objects using copyobj.
Cheng, Nestic
Cheng, Nestic 2016년 3월 29일
Thanks for reply!!! I've got some further question about using copyobj these days,try to copy axes objects to axes objects just as your mention(still failed :P) Therefor I write another Post to ask more about this! http://www.mathworks.com/matlabcentral/answers/275954-problem-with-transfer-information-from-a-axes-to-another-in-gui-using-copyobj

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by