Is it possible to get a reduced space character in a text?

조회 수: 17 (최근 30일)
Robert Berghaus
Robert Berghaus 2017년 10월 23일
편집: Walter Roberson 2017년 10월 23일
How can I change the full size of the space character to half in a legend? I need it in between numbers and a unit. For example after the number 1: t=1 s.

답변 (1개)

Walter Roberson
Walter Roberson 2017년 10월 23일
thin = char(8201); %https://en.wikipedia.org/wiki/Thin_space
phrase = sprintf('The event lasted %.3f%ss', pi, thin);
plot(1:10);
legend(phrase)
  댓글 수: 4
Robert Berghaus
Robert Berghaus 2017년 10월 23일
I use Matlab R2017a (Student), with Windows 7 (64bit Pro).
My Output is only 'opengl' Is that right?
Walter Roberson
Walter Roberson 2017년 10월 23일
편집: Walter Roberson 2017년 10월 23일
I just tested R2017a on Mac OS-X (El Capitan); I cannot be sure that the space was thin, but I saw no black line.
You could also experiment with char(8239), the non-breaking thin space.
Another way:
phrase = sprintf('The event lasted %.3f\\,s', pi);
plot(1:10);
leg = legend(phrase);
leg.Interpreter = 'latex';

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by