How to enlarge pie chart to appear more clearly?
3 views (last 30 days)
Show older comments
I have a three subplot of large data, however due to the large volume of data currently 90 entries the pie chart does not appear clearly what code can I use to enlarge it and show it more clearly y = dataset (:,4) h = pie(y);
2 Comments
Joseph Cheng
on 29 May 2016
can you expand on what you mean does not appear clearly? the pie sections? the text? a representative image sample with notation of what you'd like to change. One major question would be why do you need it as a subplot as it'll be forced to share the figure window with the other plots.
Answers (2)
Joseph Cheng
on 29 May 2016
Edited: Joseph Cheng
on 29 May 2016
Here is a quick intro example of what you can do by modifying the handles of the plots. not sure what you're going for but hopefully it's covered somewhere in here and points you to what else you can do to accomplish what you're looking for.
%%sample:
figure(1)
%3 pie charts to maximize area they can be placed would be in a triangle
%position first subplot top middle
sh(1)=subplot(2,1,1);
%generate some dummy data with 90 entries
x=randi(100,1,90);
pieH1=pie(x);
%since there are so many entries it may be hard to visualize especially
%with the text possibly overlapping
%adjust slice and text position (here we've offset every other entry)
%examine the pieH1 data and you'll see that pie slice data is odd indexes
%text is even entries.
for ind = 2:4:numel(pieH1)
pieH1(ind).Position = pieH1(ind).Position*1.1;
pieH1(ind-1).Vertices = pieH1(ind-1).Vertices*1.1;
end
%position second subplot bottom left
sh(2)=subplot(2,2,3);
%generate some dummy data with 90 entries
x=randi(100,1,90);
pieH2=pie(x);
%since there are so many entries it may be hard to visualize especially
%with the text possibly overlapping
%adjust slice and text position (here we've offset every other entry)
for ind = 2:4:numel(pieH2)
pieH2(ind).Position = pieH2(ind).Position*1.1;
pieH2(ind-1).Vertices = pieH2(ind-1).Vertices*1.1;
end
%position second subplot bottom left
sh(3)=subplot(2,2,4);
%generate some dummy data with 90 entries
x=randi(100,1,90);
pieH3=pie(x);
%since there are so many entries it may be hard to visualize especially
%with the text possibly overlapping
%adjust slice and text position (here we've offset every other entry)
for ind = 2:4:numel(pieH3)
pieH3(ind).Position = pieH3(ind).Position*1.1;
pieH3(ind).FontSize= 7; %example of making font smaller
pieH3(ind-1).Vertices = pieH3(ind-1).Vertices*1.1;
end
%
%adjust positioning of subplots
%here is just an example of adjusting the subplot position.
sh(1).Units ='normalized'; %to be normal to figure window
sh(1).Position = [sh(1).Position(1)*0 sh(1).Position(2)*.8 sh(1).Position(3:4)*1.3];
2 Comments
Joseph Cheng
on 31 May 2016
well my above code does show how to accomplish this. but the problem is even if you increase the size of the pie the allocated region for the pie chart is still extremely small especially with the number of slices.
in my example that last section shows how to adjust the size of the pie chart by adjusting the allocated area of the subplot.
looking at your data i would suggest going away from a pie chart and plotting like you did with the others but the y axis would be percentages and x be your bin.
Chad Greene
on 31 May 2016
Try this:
embiggenby = 20; % <-enter a value here; it's a percent.
% Make a plot:
subplot(3,1,2)
pie(rand(10,1))
% Get position of the plot:
pos = get(gca,'outerposition');
% Change axis position:
pos(2) = pos(2) - embiggenby/2;
pos(3) = pos(3)+ embiggenby
% Set new axis position:
set(gca,'outerposition',pos)
3 Comments
See Also
Categories
Find more on Pie Charts in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!