How do I adjust the radius of a pie chart?

4 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 14 de Mayo de 2010
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

Más respuestas (0)

Categorías

Más información sobre Pie Charts en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Productos


Versión

R2010a

Community Treasure Hunt

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

Start Hunting!

Translated by