필터 지우기
필터 지우기

Problem using copyobj

조회 수: 25 (최근 30일)
John
John 2011년 12월 5일
I have created a GUI with 2 axes. The code I generated plots data onto both axes however what I want to do is export these 2 axes onto a new figure window. Here is the following code I am using:
h1 = handles.inplane_graph;
h2 = handles.outofplane_graph;
copyobj(h1,figure(1));
copyobj(h2,figure(2));
Both graphs are copied perfectly into new figure windows, however the position of the graphs are not centered and the graphs themselves are small (the same size as they appear in the GUI). I want the graphs to be standard size and centered. Can someone please help?

채택된 답변

Walter Roberson
Walter Roberson 2011년 12월 5일
copyobj() copies everything, including the Position information. You can set() the Position after the copy.
  댓글 수: 3
Walter Roberson
Walter Roberson 2011년 12월 5일
get() the 'Units' in both cases: if you are using different Units then the positions would be very different.
You can set the axes position in normalized units:
nh1 = copyobj(h1,figure(1));
nh2 = copyobj(h2,figure(2));
set([nh1,nh2], 'Units', 'normalized', 'Position', [.2 .2 .6 .6]);
The .2 and .6 were chosen arbitrary to leave a margin of 1/10 of the figure area on all sides of the graph.
John
John 2011년 12월 5일
Thank you so much. The units were indeed what was causing the problem.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by