6
$\begingroup$

There are numerous options in Marthematica for pie chart labels positioning:

PieChart[Range[10], ChartLabels -> Placed[Range[10], "RadialCallout"], SectorOrigin -> {Automatic, 1}]

will display:

enter image description here

And this code:

Table[PieChart[{1, 2, 3}, ChartLabels -> Placed[{"a", "b", "c"}, p], 
  SectorOrigin -> {Automatic, 1}, 
  PlotLabel -> p], {p, {"RadialInner", "RadialCenter", 
   "RadialOuter"}}]

will display this:

enter image description here

How can one obtain labels so that only labels for several smallest sections are displayed outside the pie, using callouts, and all other labels are in the center or close to the center of correspondent sections? Like this:

enter image description here

Or:

enter image description here

$\endgroup$

1 Answer 1

11
$\begingroup$

Wrapping input data with Labeled:

PieChart[Labeled[#, #, If[# < 5, "RadialCallout", "RadialCenter"]] & /@ Range[10], 
         SectorOrigin -> {Automatic, 1}]

enter image description here

PieChart3D[Labeled[#, #, If[# < 5, "RadialCallout", "RadialCenter"]] & /@ Range[10], 
  SectorOrigin -> {Automatic, 1}, 
  ChartElementFunction -> ChartElementDataFunction["ProfileSector3D", "Profile" -> 3.1`]]

enter image description here

Using LabelingFunction:

PieChart[Range[10], SectorOrigin -> {Automatic, 1},
  LabelingFunction -> (Placed[#, If[# < 5, "RadialCallout", "RadialCenter"]] &)]

enter image description here

PieChart3D[Range[10],  SectorOrigin -> {Automatic, 1}, 
 LabelingFunction -> (Placed[#, If[# < 5, "RadialCallout", "RadialCenter"]] &), 
 ChartElementFunction -> ChartElementDataFunction["ProfileSector3D", "Profile" -> 3.1`]]

enter image description here

See also: Customizing individual labels in a PieChart

$\endgroup$
2
  • $\begingroup$ Great answer this adds a lot of flexibility! $\endgroup$ Nov 11, 2014 at 13:17
  • $\begingroup$ @Dragan, thank you for the accept; and welcome to mma.se. $\endgroup$
    – kglr
    Nov 11, 2014 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.