How to enlarge pie chart to appear more clearly?

20 次查看(过去 30 天)
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 个评论
Joseph Cheng
Joseph Cheng 2016-5-29
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.
Waleed Alhaider
Waleed Alhaider 2016-5-30
Hi Joseph I hope this image would help. The pie section does not appear clearly the text. Any help to make the image more clear is highly appreciated. As for why do you need the three subplot to make it easier to explain the relation within the same image no need to set up to windows and open multiple images I am just not happy with the pie section

请先登录,再进行评论。

回答(2 个)

Joseph Cheng
Joseph Cheng 2016-5-29
编辑:Joseph Cheng 2016-5-29
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 个评论
Waleed Alhaider
Waleed Alhaider 2016-5-31
The above code was really helpful, definitely will be useful in the near future, however in this particular case I am just looking to make the pie chart bigger for people to see.
Joseph Cheng
Joseph Cheng 2016-5-31
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
Chad Greene 2016-5-31
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 个评论

请先登录,再进行评论。

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by