how can I copy multiple Matlab.fig files, each with multiple subplots, into a single plot
조회 수: 4 (최근 30일)
이전 댓글 표시
I am trying to write a script to programmatically open multiple FIG files (each of which has a single plot consisting of 3 subplots) and then place then on a single plot, and then save that as a FIG file. I have followed an example posted in this site, modified with my file names. What happens is that only the last subplot from each FIG file is placed on the new figure (with handle h3). How do I get all the original subplots to appear on the new plot? I have attached the two FIG files.
h1 = openfig('ROC_whole_b1','reuse')
ax1 = gca;
h2 = openfig('ROC_whole_b2','reuse')
ax2 = gca;
h3 = figure;
s1 = subplot(1,2,1)
s2 = subplot(1,2,2)
fig1 = get(ax1,'children');
fig2 = get(ax2,'children');
copyobj(fig1,s1);
copyobj(fig2,s2);
댓글 수: 2
Walter Roberson
2014년 2월 2일
Do the figures contain any uicontrol or uipanel? Do all the figures use the same colormap, or alternately are all objects in the figure colored by RGB ?
답변 (2개)
Amit
2014년 2월 1일
You need to get handle for all the subplots in each figure.
% First open a new figure
hh = figure;
% Open First File
h1 = openfig('ROC_whole_b1','reuse');
axesVal = findobj(gcf,'Type','axes');
handle = get(axesVal,'Children');
figure(hh);
for j = 1:3
s = subplot(3,2,j); % You said 3 subplots in each figure and total 2 figures. Thus 6 section on the figure
copyobj(handle{j},s);
end
You get the point now.
댓글 수: 6
Amit
2014년 2월 7일
Jeff,
I am a graduate student and I use Matlab significantly. One thing I know is what can be a headache and how I can avoid it. Sometimes writing a script is better than re-engineer something as re-engineering requires more work than simply writing it.
In you case, you have 3 different axes and the person who wrote the plotting file wrote it nicely for a certain purpose. Now you're trying to take that plot and reengineer it to do it. If I was in your shoes, I'll simply study the original script and change it to do anything I want. (I did read the plotting script and it is a simpler fix to me to re-write it to serve my purpose).
As far as passing the question, you can probably repost your issue!
참고 항목
카테고리
Help Center 및 File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!