필터 지우기
필터 지우기

Reduce the line height for an annotation textbox

조회 수: 5 (최근 30일)
giannit
giannit 2020년 4월 28일
댓글: Ameer Hamza 2020년 5월 1일
The following code
annotation('textbox','String',{'\fontsize{10}TEST', '\fontsize{15}7,987,157', '\fontsize{10}+8,829'},'FontName','Consolas')
creates this box
One can notice that the third string is farther than the first one from the the middle one.
Moreover, by increasing the fontsize of the middle string, the last one will go even far away. Also the first string will go a little far away.
annotation('textbox','String',{'\fontsize{10}TEST', '\fontsize{25}7,987,157', '\fontsize{10}+8,829'},'FontName','Consolas')
Is there a way to reduce the line height or, similarly, to reduce the distance between the strings?
  댓글 수: 8
Ameer Hamza
Ameer Hamza 2020년 4월 29일
I guess these functions were never intended for sophisticated text formatting with multi-line text. That is why there are some issues if the command becomes complex.
Adam Danz
Adam Danz 2020년 4월 29일
편집: Adam Danz 2020년 4월 29일
The problem is reproduced in r2020a using Windows 7. It appears that the space between lines n and n+1 is based on the fontsize that is in line n.
Note that the default verticalAlignment of the annotation is "top" but that only affects the entire text box as a whole, not each component within the textbox.

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

채택된 답변

giannit
giannit 2020년 5월 1일
A workaround is simply to move the fontsize command of the last string to the middle string, that is
annotation('textbox','String',{'\fontsize{10}TEST', '\fontsize{25}7,987,157\fontsize{10}', '+8,829'},'FontName','Consolas')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by