How to show both value and percentage in a piechart

5 vues (au cours des 30 derniers jours)
Yajie Liang
Yajie Liang le 15 Avr 2020
Commenté : Ameer Hamza le 17 Avr 2020
Hi, I googled a while but did not find a good resolution. Is there a simple way to do that? thanks

Réponse acceptée

Ameer Hamza
Ameer Hamza le 15 Avr 2020
Try this
X = [1/3 2/3];
value = compose(['Val=%.3f'], X);
percents = compose([newline 'P=%.3f%%'], X/sum(X)*100);
pie(X, strcat(value, percents))
  2 commentaires
Yajie Liang
Yajie Liang le 16 Avr 2020
Great! Thanks a lot!
Ameer Hamza
Ameer Hamza le 17 Avr 2020
I am glad to be of help.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by