pie chart subdivision of a sector

1 回表示 (過去 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 Center および File ExchangePie Charts についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by