How do I adjust the radius of a pie chart?

4 次查看(过去 30 天)
I would like to specify the radius of a pie chart relative to the figure window.
Currently if the figure window is re-sized with the mouse the pie chart within automatically adjusts to fill the window.

采纳的回答

MathWorks Support Team
The ability to specify the radius of a pie chart is not available in MATLAB.
As a workaround, you can adjust the size and position of the axis containing the pie chart and get a similar effect. The code below demonstrates how this can be done.
close all; clc;
pieData = [10 20 30 40 50]; % Size of pie slices
pieHandle = pie(pieData); % Get vector of handles to graphics objects
pieAxis = get(pieHandle(1), 'Parent');
pieAxisPosition = get(pieAxis, 'Position');
newRadius = 0.50; % Change the radius of the pie chart
deltaXpos = 0.2; % Move axis position left or right
deltaYpos = 0.2; % Move axis position up or down
hText = text(-1.7, -1.4, 'PRESS ANY KEY TO ADJUST THE RADIUS');
pause;
delete(hText);
% Compute newPieAxisPosition
% To keep the axis centered (Xpos, Ypos) also need to be adjusted.
% Position is a four-element vector: [left bottom width height]
% Translate (left, right) by (deltaXpos, deltaYpos) and Scale (width, height) by newRadius.
newPieAxisPosition = (pieAxisPosition + [deltaXpos deltaYpos 0 0]) .* [1 1 newRadius newRadius];
set(pieAxis, 'Position', newPieAxisPosition); % Set pieAxis to new position

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Pie Charts 的更多信息

标签

尚未输入任何标签。

产品


版本

R2010a

Community Treasure Hunt

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

Start Hunting!

Translated by