pie chart subdivision of a sector

3 次查看(过去 30 天)
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

更多回答(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