Thursday, April 16, 2020

How to display both percentage and value in a piechart in matlab

https://www.mathworks.com/matlabcentral/answers/518138-how-to-show-both-value-and-percentage-in-a-piechart Thanks to Ameer Hamza, we have the answer now: X = [1/3 2/3]; value = compose(['Val=%.3f'], X); percents = compose([newline 'P=%.3f%%'], X/sum(X)*100); pie(X, strcat(value, percents))

1 comment:

Michael Liang said...

A more complete version for Pie chart:

X = [length(CT_OS) length(CT_active_evoked)-length(CT_OS) length(CT_active)-length(CT_active_evoked)];

value = compose(['=%.1f'], X);
percents = compose([newline 'P=%.1f%%'], X/sum(X)*100);
labels={'OS','NOS','non-evoked'};

pie(X, strcat(labels,value, percents))
title('CT')