I've created a multi-line title and I need a second string of text right aligned on the second line:
t = title({['\fontsize{14}','First line'];['\fontsize{10}',sprintf('Second line left aligned %s',stringarray),'Second line right aligned']},'FontWeight','Normal');
I'm striking out on how to do this. Should I create another line of text and try to find the position of the title then right align? Or is there a way to do this within a multi-line title?

댓글 수: 2

Adam Danz
Adam Danz 2021년 10월 29일
In Matlab R2020b or later, you can use the subtitle() function along with the TitleHorizontalAlignment and LabelHorizontalAlignment properties.
Chunru
Chunru 2021년 10월 30일
Thanks for introducing the subtitle() function, which may be helpful in many other applications. However, it won't help if we want to have part of string to be aligned left and other aligned right as OP asked.

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

 채택된 답변

Chunru
Chunru 2021년 9월 12일
편집: Chunru 2021년 9월 12일

0 개 추천

figure;
plot(randn(10,1))
t = title({['\fontsize{14}','First line']; ...
' '}, ...
'FontWeight','Normal');
axPos = get(gca, 'Position');
xl =xlim;
%t.Position(1) = xl(2);
text(xl(1), t.Position(2), 'Second Line Left Aligned', ...
'HorizontalAlignment', 'left', 'VerticalAlignment', 'bottom');
text(xl(2), t.Position(2), 'Second Line Right Aligned', ...
'HorizontalAlignment', 'right', 'VerticalAlignment', 'bottom');
set(gca, 'Position',axPos);

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Labels and Annotations에 대해 자세히 알아보기

제품

릴리스

R2018a

질문:

2021년 9월 12일

댓글:

2021년 10월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by