필터 지우기
필터 지우기

pie chart subdivision of a sector

조회 수: 5 (최근 30일)
Maria Ali
Maria Ali 2021년 12월 26일
댓글: Maria Ali 2021년 12월 26일
i have to create a pi chart as shown in the picture from the given data. how can i subdivide a sector as is shown in the picture

채택된 답변

Chunru
Chunru 2021년 12월 26일
x = [73.1 39.3 29.9 8.2 7.2 6.2];
xp = x/sum(x);
x1 = [xp(1:2) sum(xp(3:end))];
x2 = xp(3:end);
figure; hold on
theta0 = 0;
colors = ['r','g','b','c','m','y', 'w'];
for i=1:length(x1)
theta1 = theta0 + x1(i)*360;
theta = linspace(theta0, theta1, 50)';
%[0.5*cosd(theta); 1*cosd(flip(theta))], [0.5*sind(theta); 1*sind(flip(theta))]
patch([0.5*cosd(theta); 1*cosd(flip(theta))], [0.5*sind(theta); 1*sind(flip(theta))], colors(i));
text(0.75*cosd(mean(theta)), 0.75*sind(mean(theta)), num2str(i))
theta0 = theta1;
end
theta0 = sum(x1(1:end-1))*360;
for i=1:length(x2)
theta1 = theta0 + x2(i)*360;
theta = linspace(theta0, theta1, 50)';
%[0.5*cosd(theta); 1*cosd(flip(theta))], [0.5*sind(theta); 1*sind(flip(theta))]
patch([1*cosd(theta); 1.5*cosd(flip(theta))], [1*sind(theta); 1.5*sind(flip(theta))], colors(3));
text(1.25*cosd(mean(theta)), 1.25*sind(mean(theta)), char('A'+(i-1)))
theta0 = theta1;
end
axis equal
axis off
  댓글 수: 1
Maria Ali
Maria Ali 2021년 12월 26일
Thank you so much for your help.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by