how to avoid the newline in figure annotation, please help. I give the example code below.

15 ビュー (過去 30 日間)
rng=10;
f1=50;
figure
annotation('textbox',[0.0202708333333333 0.328350515463918 0.220875 0.579278350515467],'String',{'3D distance = ',rng,'2D distance = ',f1});

採用された回答

Chunru
Chunru 2021 年 6 月 23 日
Using cell string, each cell will be in a new line. Change the cell string to char array as follows:
rng=10;
f1=50;
figure
plot(rand(10,1))
annotation('textbox',[0.0202708333333333 0.328350515463918 0.220875 0.579278350515467],...
'String',sprintf('3D distance = %.0f \n 2D distance = %.0f', rng, f1),...
'FitBoxToText','on', 'EdgeColor',[1 1 1],'Interpreter','latex');
  3 件のコメント
Chunru
Chunru 2021 年 6 月 23 日
Remove the space after \n in the sprintf command.
Muhammad Sajid Haroon
Muhammad Sajid Haroon 2021 年 6 月 23 日
It works great. thank you so much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by