フィルターのクリア

Change the position of a pie chart

31 ビュー (過去 30 日間)
Alessia Giorgi
Alessia Giorgi 2022 年 12 月 21 日
コメント済み: Mathieu NOE 2023 年 1 月 31 日
Hi everyone,
I'd like to change the position of a pie chart from "Initial position" to "Final position" (see figure below).
Can anyone help me?
Thank you.
Alessia

回答 (2 件)

Mathieu NOE
Mathieu NOE 2022 年 12 月 21 日
hello
try this
X = [0.1 0.2 0.2];
subplot(1,2,1),
pie(X);
subplot(1,2,2),
pie(X);
set(gca, 'CameraViewAngleMode', 'manual', 'CameraTargetMode', 'manual', ...
'CameraPositionMode', 'manual');
ang = 3*pi/2;
set(gca, 'CameraUpVector', [sin(ang), cos(ang), 0]);
  3 件のコメント
Mathieu NOE
Mathieu NOE 2022 年 12 月 22 日
My pleasure !
If my submission fullfills your request, do you mind accepting it ?
tx
Mathieu NOE
Mathieu NOE 2023 年 1 月 31 日
hello again
If my submission fullfills your request, do you mind accepting it ?
tx

サインインしてコメントする。


Adam Danz
Adam Danz 2022 年 12 月 21 日
編集済み: Adam Danz 2022 年 12 月 22 日
The solution below rotates the set of objects that create a pie chart by using an hgtransform.
The text label alignment needs updated since the initial alignment is designed to be to the left of the pie segments but after rotation, the labels should be centered above the segments. The text alignment adjustment is fairly easy for this example but if the pie chart contained all segements around the circle, a bit more work would be needed to assign the best alignment property values.
% Create initial pie chart
ax = axes();
h = pie([.167 .167 .167]);
% rotate 90 deg clockwise
ang = -90; % angle of rotation, degrees, negative is clockwise
tform = hgtransform('Parent',ax);
set(h, 'Parent', tform)
Rz = makehgtform('zrotate',ang*pi/180);
set(tform,'Matrix',Rz)
% Adjust text label alignment
tobj = findobj(h,'type','text');
set(tobj, 'VerticalAlignment', 'Bottom', 'HorizontalAlignment', 'Center')

カテゴリ

Help Center および File ExchangePie Charts についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by