How to create pie chart using input from text file?
8 views (last 30 days)
Show older comments
I want to create pie chart that represent colour and percentages. Right now, I already read text file using text scan which convert data into cell array. As from my understand to create pie chart, X should be in vector or matrix and I already convert from cell to matrix using cell2mat and it does not work. I am trying to use categorical array and as a result size of pie chart is equally divided. How to make size of each slices follow to percentages value? here is my code,
load_data = fopen('out.txt');
C = textscan(load_data, '%q %q %q %s %s %q');
fclose(load_data);
cellpercentage = C{1,6};
matrix = reshape(cellpercentage,1,8);
x = categorical (matrix)
pie(x)
but if I manually write X = [10,45,15,30] size of slices in pie chart followed value X.
0 Comments
Answers (0)
See Also
Categories
Find more on Pie Charts in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!