Using a char matrix as a text legend

I would like using the text contained in a char matrix named "textlegend" to fill a legend of a pie figure.
my code to generate the pie:
pie([total(:,2)]);
then I want to generate the legend for the pie. Each part of the pie correspond to a ligne in the textlegend matrix. for example the first part of the pie must have textlegend(1,:) as legend the second part of the pie textlegend(2,:), etc... the size of textlegend matrix fit with the number of pie part of course! but is not constant!
Thanks

 採用された回答

dpb
dpb 2014 年 11 月 28 日

0 投票

txt=num2str(total(:,2),'%.2f');
Fixup format string as desired, of course.
NB: text works equally well with cell strings which can be simpler to deal with as don't need the second subscript expression altho if use the vector form where provide x,y coordinates as vectors during call the above array form works transparently, too.

1 件のコメント

nicolas
nicolas 2014 年 11 月 28 日
thanks it works great

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

その他の回答 (0 件)

カテゴリ

製品

質問済み:

2014 年 11 月 28 日

コメント済み:

2014 年 11 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by