How to apply an existing text object to a new figure

4 次查看(过去 30 天)
In my script I have created text objects for a figure's title, y label and x label and then modified these objects' properties as desired as seen here:
figure(1)
plot((1:length(theta))/dataframe(n).videoObject.FrameRate,theta,'Color',bankColour,'Marker','.','LineStyle','none')
xlab1=xlabel('Time (seconds)');
ylab1=ylabel('Bank angle (degrees)');
tit1=title(['Bank angle - ',dataframe(n).birdID],'Interpreter','none');
xlab1.FontSize=14;
xlab1.FontWeight='bold';
xlab1.FontName='calibri';
ylab1.FontSize=14;
ylab1.FontWeight='bold';
ylab1.FontName='calibri';
tit1.FontSize=14;
tit1.FontName='calibri';
tit1.FontWeight='bold';
Later in the script I want to make another figure using exactly the same labels and associated properties (i.e. FontSize, FontWeight and FontName).
As these labels exist as text objects in the form of xlab1, ylab1 and tit1, is there a way of calling these objects to my new figure without having to create new objects and rewriting the above code again for the new figure?

采纳的回答

Walter Roberson
Walter Roberson 2020-6-9
编辑:Walter Roberson 2020-6-9
newfig = figure();
newax = axes(newfig);
xlab2 = copyobj(xlab1, newax);
newax.XRuler.Label = xlab2;
ylab2 = copyobj(ylab1, newax);
newax.YRuler.Label = ylab2;
tit2 = copyobj(tit1, newax);
newax.Title = tit2;
Note: the copyobj() is important: without it, the text items would disappear from the original location.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

标签

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by