Hi Alberto,
I understand that you are encountering issues while plotting data on the pie chart. From my understanding of the question, your requirements are as follows
- You want to hide the labels for strings with percentage = 0
- Achieve circular arrangement of numbers without overlapping
I ran your code on my end to reproduce the issue you are facing. I observed that the overlapping is because you are plotting data points with 0% share on the pie chart. In case you do not wish to show the labels with 0% share on the legend and resolve the overlapping the issue, you can modify the following line in your code
matrix_new = matrix(matrix(:,2) < 5, :);
to the following line. This will omit the labels having percentage == 0
matrix_new = matrix((matrix(:,2) < 5) & (matrix(:,2) > 0), :);
The pie chart obtained on executing the code after modification is shown below
To accommodate both of your requirements, you can extract all the labels with percentage == 0. Once you have the list, leverage the findobj function to get handles to each label and then use set to modify the 'String' property to ''
x = labels(percentages == 0);
textObj = findobj(p, 'String', x(i));
set(textObj, 'String', '');
I hope this helps.