- If sum(X) ≤ 1, then the values in X directly specify the areas of the pie slices. pie draws only a partial pie if sum(X) < 1.
- If sum(X) > 1, then pie normalizes the values by X/sum(X) to determine the area of each slice of the pie.
representing data in pie chart
조회 수: 8 (최근 30일)
이전 댓글 표시
hello everybody i wanna represent data in pie chart:
and i got stuck when the sum of values is less than 100:
a2=input("please enter numeric values using '[ ]' : ");
if sum (a2)>=100
pie(a2)
else
labels = {'data','Other'};
pie(sum(a2),100-sum(a2),labels)
댓글 수: 0
답변 (1개)
Monisha Nalluru
2021년 4월 14일
But if you dont want a partial pie when sum(X) < 100 you can use if condition and calculate the other variable value and plot it.
As an example
a2=input("please enter numeric values using '[ ]' : ");
if sum(a2)>100
disp('Invalid Entry: Sum Greater than 100');
elseif sum(a2) == 100
pie(a2);
else
others = 100 - sum(a2);
a2 = [a2, others];
pie(a2);
end
Hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Pie Charts에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!