How can i place saved figures into a new figure as subplots?

조회 수: 18 (최근 30일)
Yasmin Samy
Yasmin Samy 2018년 10월 18일
댓글: Yasmin Samy 2018년 10월 26일
Hello, I am trying to place my plotted figures (saved as .fig) as subplots in one figure. The problem i face is that they axis totally changes. I would like to place them in subplots without any changes.
I tried the code at https://www.mathworks.com/matlabcentral/answers/101806-how-can-i-insert-my-matlab-figure-fig-files-into-multiple-subplots but still it changed the axis and the details of the figures. thanks
  댓글 수: 8
Yasmin Samy
Yasmin Samy 2018년 10월 19일
Thanks Walter, that makes sense. Can you guide me as in how to do that exactly...

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

답변 (1개)

Jan
Jan 2018년 10월 20일
편집: Jan 2018년 10월 20일
I assume, all you have to do is to replace:
h7 = figure; %create new figure
s1 = subplot(2,3,1); %create and get handle to the subplot axes
fig1 = get(ax1,'children'); %get handle to all the children in the figure
copyobj(fig1,s1); %copy children to new parent axes i.e. the subplot axes
by
h7 = figure; %create new figure
newAxes = copyobj(ax1, h7); %copy axes to new figure
If you want to change the position of the new axes object, do this afterwards.
  댓글 수: 4
Jan
Jan 2018년 10월 26일
@Yasmin Samy: To be exact, you cannot "put a figure in a subplot". While a "figure" is the complete window with title bar and menus, a "subplot" is an axes object. Does "playing with the figure position" mean the position of the axes? Confusing.
Yasmin Samy
Yasmin Samy 2018년 10월 26일
@Walter Roberson: Thanks for your comment, i guess plotting them all in the same figure where they overlap each other, then use Position to place them in the required place (and resize them as well). Thanks for that.
@Jan: Yes i meant using Position to place them where i want them instead of using subplot. I tried doing that with 2 plots, having them plotted (they overlap each other) full size in the same figure. Then i manually resized and put them in the place i would want them to be (manually doing what i was hoping 'subplot' would do).

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

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by