How can i place saved figures into a new figure as subplots?
古いコメントを表示
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 件のコメント
Jan
2018 年 10 月 18 日
Please explain the details: "it changed the axis and the details of the figures" is to vague to understand, what you observe and what you want to get instead. Perhaps some screenshots are useful.
Yasmin Samy
2018 年 10 月 18 日
Jan
2018 年 10 月 19 日
These two images do not clarify, what you use as input, which code you use, why the ranges of the data are different and where the legends, titles and annotations are coming from. Please try to explain the problem more clearly, such that the readers can reproduce what you get and suggest modifications. Without seeing your code it is hard to guess, what you want to change.
Walter Roberson
2018 年 10 月 19 日
The code given in that Question is not nearly a complete solution. I have posted more complete code; https://www.mathworks.com/matlabcentral/answers/262265-duplicating-an-imshow-image-into-a-new-figure-without-using-imshow#comment_332459
Yasmin Samy
2018 年 10 月 19 日
Walter Roberson
2018 年 10 月 19 日
copyobj of the axes children is not enough: you need to copy the axes properties as well.
Yasmin Samy
2018 年 10 月 19 日
回答 (1 件)
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 件のコメント
Yasmin Samy
2018 年 10 月 25 日
Walter Roberson
2018 年 10 月 25 日
編集済み: Walter Roberson
2018 年 10 月 25 日
You would use multiple copies of the second line to copy all of the axes into the h7 figure. You would not need "hold on".
You would have to set the Position properties after doing the copying.
Note: this approach is likely to mess up legends, and possibly colorbar plots as well.
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
2018 年 10 月 26 日
カテゴリ
ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!