Pie chart without labels

조회 수: 53 (최근 30일)
Ansh
Ansh 2019년 8월 15일
댓글: Ansh 2019년 8월 15일
Hi all, I have created a pie chart but I want to remove all the labels on the exterior of the pie so I just have the partitioned pie in the figure. Does anyone know how to do this? I have seen options to change the labels but not to remove them entirely from the pie chart (at least if they are not visible on the figure that would be also be fine) no-legend-pie-chart.pngThis pie chart is an example of what I would like to achieve. Hopefully this makes it a bit clearer. Thanks in advance!
  댓글 수: 1
Rik
Rik 2019년 8월 15일
What code are you currently using?

댓글을 달려면 로그인하십시오.

채택된 답변

Rik
Rik 2019년 8월 15일
No need for fragile findobj(ax,__) calls (which may return a lot more than just the pie labels). You can either set the labels to an empty char array, or delete the text objects using the handles returned by pie:
figure(1),clf(1)
X = 1:3;
labels = repmat({''},size(X));%option 1
p = pie(X,labels);
delete(findobj(p,'Type','text'))%option 2
You can pick either option. I would personally vote for the second, because then you remove the object, instead of making invisible or setting the content to an empty array.
  댓글 수: 1
Ansh
Ansh 2019년 8월 15일
I like this answer, two options for whoever is reading this and came across the same thing. Thanks! I have accepted your answer. I have gone with the second option as you advised since this is the preferred solution I wanted anyway.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Oren B
Oren B 2019년 8월 15일
f = figure(1);
X = [1 3 0.5 2.5 2];
ax= axes('parent',f);
pie(X,'parent',ax);
%% get the axis text children
TextChildren = findobj(ax,'Type','text');
%% set the text visible off
set(TextChildren,'visible','off')

카테고리

Help CenterFile Exchange에서 Pie Charts에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by