MATLAB: Pie chart label overlapping

groupinglabelspiechart

Hey guys so I have a pie chart with labels like 1%,2% <1% and because there are 100 values it overlaps quite a lot.
I am able to remove all labels with delete(findobj(p,'Type','Text'))
Is there any way to remove just the ones with <1% or somehow group the labels together?

Best Answer

Use the pie() output handle to obtain the text objects.
h = pie(. . .);
th = findobj(h,'Type','Text'); % text handles
Determine which text strings begin with "<"
isSmall = startsWith({th.String}, '<'); % r2016b or later
% isSmall = ~cellfun(@isempty, regexp({th.String},'^<')); % any matlab release
Either delete the text objects or replace their String values with empties.
delete(th(isSmall));
%or
set(th(isSmall),'String', '')
Demo:
h = pie(sort([linspace(0,1,20),linspace(.5,2,10),linspace(1,10,20)]));