Copy XLabel from axes: R2014a

조회 수: 3 (최근 30일)
Pankaj
Pankaj 2016년 10월 6일
댓글: Pankaj 2016년 10월 9일
Hello
I was trying to copy xlabel text from one axes to another with following code. What I exactly want is XLabel of a1f1 and a1f2 same.
f1 = figure;
a1f1 = axes;
XLa1f1 = xlabel('XLabel of axes');
f2 = figure;
a1f2 = axes;
set(a1f2, 'XLabel', XLa1f1)
The above code produces following error:
Error using set
XLabel must be an existing text child of axes
Can someone tell me how to work around this.
I am using R2014a
Thanks

채택된 답변

Wayne King
Wayne King 2016년 10월 6일
편집: Wayne King 2016년 10월 6일
You should say what version of MATLAB you are using because handle graphics changed appreciably in 14b.
R2014b and on
f1 = figure;
a1f1 = axes;
XLa1f1 = xlabel('XLabel of axes');
f2 = figure;
ax = gca;
ax.XLabel.String = XLa1f1.String;
Prior to 14b:
f1 = figure;
a1f1 = axes;
XLa1f1 = xlabel('XLabel of axes');
f2 = figure;
xlab = get(XLa1f1,'String');
xlabel(xlab)
  댓글 수: 4
Wayne King
Wayne King 2016년 10월 6일
You should accept the answer if that worked for you.
Pankaj
Pankaj 2016년 10월 9일
Accepted. Usually I gave sufficient time to others also for answering.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by