how to write the percentage into pie chart?
11 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Stephen23
2016-5-22
L = {'A','B','C','D','E'};
X = [ 1, 3,0.5,2.5, 2];
H = pie(X);
%
T = H(strcmpi(get(H,'Type'),'text'));
P = cell2mat(get(T,'Position'));
set(T,{'Position'},num2cell(P*0.6,2))
text(P(:,1),P(:,2),L(:))
Creates this:
10 个评论
Jaladhar Mahato
2018-1-12
I got the answer. I have to just put 'FontSize' at the end text comment.
text(P(:,1),P(:,2),L(:),'FontSize',18)
Gwen
2020-8-31
Hi, this was a really helpful answer. Thank you @Stephen Cobeldick. I am wondering if you can help me relocate some of the external text labels. You'll notice "NH4+" and "Na+" are written too close to the pie chart...
Thanks in advance!
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Pie Charts 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!