Saving an image from subplots in a uipanel

3 ビュー (過去 30 日間)
davidwriter
davidwriter 2018 年 6 月 7 日
コメント済み: davidwriter 2018 年 6 月 8 日
I am running a live system that is controlled via a complex figure. One part of this figure is a uipanel (named handles.APlot) that contains three subplots - so:
subplot(311, 'Parent', handles.APlot);
handles.plotx=animatedline('Color','b','LineWidth',1);
ylabel('x (m)');
xlabel('time (s)');
subplot(312, 'Parent', handles.APlot);
handles.ploty=animatedline('Color','b','LineWidth',1);
ylabel('y (m)');
xlabel('time (s)');
subplot(313, 'Parent', handles.APlot);
handles.plotz=animatedline('Color','b','LineWidth',1);
ylabel('z (m)');
xlabel('time (s)');
This is continually updated until the end of a run:
hold on;
addpoints(handles.plotx,timeelapsed,X_mean);
addpoints(handles.ploty,timeelapsed,Y_mean);
addpoints(handles.plotz,timeelapsed,Z_mean);
hold off;
where timeelapsed is the time after start in seconds and the three means are positions in X, Y and Z. At the end of a run we get three nice graphs showing the events in X, Y, Z during the run.
My question is: How can I save these graphs to a file? A uipanel is not a figure so I can't access a frame. Matlab seems to indicate that there is an internal figure generated when you place axes(subplots) on a uipanel, but I can't find any way to access this.

採用された回答

Daniel Dolan
Daniel Dolan 2018 年 6 月 7 日
You could copy the axes objects to a temporary figure.
name={'plotx' 'ploty' 'plotz'};
pos=getpixelposition(get(handles.(name{1),'Parent');
new=figure('Units','pixels','Position',pos);
for n=1:numel(name)
copyobj(handels.(name{n}),new);
end
print(new,'-dpdf','myplots.pdf');
delete(new);
  1 件のコメント
davidwriter
davidwriter 2018 年 6 月 8 日
A minor modification and it worked perfectly - thank you.
name={'plotx' 'ploty' 'plotz'};
pos=getpixelposition(handles.APlot');
newfig=figure('Units','pixels','Position',pos, 'Visible','off');
for n=1:numel(name)
copyobj(handles.(name{n}),newfig);
end
saveas(newfig, 'PlotXYZ.jpg');
delete(newfig);

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by