How to add blank space using text function?

Using text function,
x = 1;
y = 1;
str1 = '1 2 3 4 5 6 7 8 9';
str2 = '4 5 6';
text(x, y, {str1; str2})
I would like to center str2 under str1 in the plot. Using a blank space before the characters in str2 does not seem to shift the characters appropriately. How can blank spaces be entered?

 채택된 답변

Star Strider
Star Strider 2017년 6월 13일

0 개 추천

Use the 'HorizontalAlignment' name-value pair option.
This does what you want when I ran it (in R2017a):
text(x, y, {str1; str2}, 'HorizontalAlignment','center')

추가 답변 (0개)

카테고리

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

제품

태그

질문:

2017년 6월 13일

답변:

2017년 6월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by