How to reconstruct a figure with a "line" variable

조회 수: 40 (최근 30일)
Nick Brewer
Nick Brewer 2019년 6월 15일
답변: Walter Roberson 2019년 6월 16일
I have something like
% Code running to generate x- and y- data
h = plot(xData, yData,'propertyname', 'propertyvalue')
save('Filename')
When I open 'Filename.mat' I can see 'h' in the workspace with all the properties of the line I plotted as '1x1 Line'.
I would like to, in a different script, create a new figure and axes and plot that line with all the properties it has. I know how to get all the properties using h.XData, h.YData, h.MarkerSize, etc, but I would like there to be somemore efficient command like
f=figure
set(f,'addplot',h)
Thanks!
  댓글 수: 2
dpb
dpb 2019년 6월 16일
"...would like there to be somemore efficient command"
There is --it's savefig and openfig
Nick Brewer
Nick Brewer 2019년 6월 16일
But I would like to be able to save several different plots and later, along with the saved properties, mix and match them in different figures.

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

채택된 답변

Walter Roberson
Walter Roberson 2019년 6월 16일
You cannot directly copy a line() object to a figure. You can copy a line() object to an axes, or you can copy an axes to a figure.
%entire axes
f = figure;
hax = get(h,'Parent');
copyobj(hax, f);
or
%line only
f = figure;
fax = axes('Parent', f);
copyobj(h, fax);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by