# Pie chart plot formatting

Mathematica Asked by wiscoYogi on August 23, 2020

I have been looking through numerous stack posts to answer 1-4 below.
I am trying to generate a pie chart with several very small slices that have long labels.

1. when I do the callouts how can I eliminate the dots that point to the slices of the pie? I’m really confused because on the examples on the PieChart function on the Mathematica website the labels don’t work out.
2. how do I get the labels not to overlap? I tried both "RadialCallout" and "VerticalCallout" but the labels themselves are so small
3. how can I get the sides of the plot not get chopped off while still using "VerticalCallout"? I tried playing with the padding parameter but my labels still get chopped
4. how can I get the pie chart title closer to the plot?

Here’s a working example of my code:

    dat  = {0.001, 0.001, 0.001, 1, 2, 3, 4};
labels = {"bbbbbbbbbbbbbb", "ccccccccccccccccccccc",
"afsafasfasfasfasfsafsab", "casfasfafsafsafsafsa",
"gwegwgwhhtrwhtrjrjwtud"};
labeledDat =
Labeled[dat [[#]], labels[[#]], "VerticalCallout"] & /@
Range[Length[dat]]

PieChart[labeledDat, SectorOrigin -> {Automatic, 1},
PlotLabel -> "Donut Plot", ColorFunction -> "Rainbow"]



I am not sure, but I am afraid that your four questions can only be answered by writing code yourself so that you can fully handle the labeling. I post two figures. First, code is given to make a grid that may help you to put labels in their exact positions; therefore just 'uncomment/comment' the ", grids" in the code for the figure.

grids = {
Table[{Thick, Line[{{-5, i}, {5, i}}]}, {i, -2, 2, 1}],
Table[{Thin, Line[{{-5, i}, {5, i}}]}, {i, -2, 2, 0.1}],
Table[{Thick, Line[{{i, -5}, {i, 5}}]}, {i, -5, 5, 1}],
Table[{Thin, Line[{{i, -5}, {i, 5}}]}, {i, -5, 5, 0.1}],
Table[Text[
Style[ToString[i], 16, Background -> White], {3.5, i}, {0,
0}], {i, -2, 2, 1}],
Table[Text[
Style[ToString[i], 16, Background -> White], {i, 2.1}, {0,
0}], {i, -5, 5, 1}]
};


In the first figure I restrict the code by using the call outs of MMA. The pie chart title is now close to the plot. I took the liberty to make three of the long labels even longer by showing the rounded percentage of the whole (0.001/10.003 times 100).

dat = {0.001, 0.001, 0.001, 1, 2, 3, 4};
labels = Table[" ", {[email protected]}];
labeledDat = Labeled[dat[[#]], labels[[#]], "RadialCallout"] & /@ Range[Length[dat]];
fig1 = Framed[PieChart[
labeledDat, SectorOrigin -> {Automatic, 1}, PlotLabel -> None,
ColorFunction -> "Rainbow",
ImagePadding -> {{160, 100}, {0, 0}},
Epilog ->
{
Text[Style["Donut Plot", Black, Bold, 24], {0.0, 2.25}, {0, 0}],

Text[
Style["bbbbbbbbbbbbbb (0.1%)nccccccccccccccccccccc (0.1%)n
aaaaaaaaaaaaaaaaaaaaaaa (0.1%)", 13,
FontFamily -> "CourierNew"], {-4.6, -0.}, {-1, 0}],

Text[
FontFamily -> "CourierNew"], {-2.35, 0.72}, {1, 0}],
Text[
Style["afsafasfasfasfasfsafsab", 13,
FontFamily -> "CourierNew"], {-0.9, 2.12}, {1, 0}],
Text[
Style["casfasfafsafsafsafsa", 13,
FontFamily -> "CourierNew"], {2.35, 0.67}, {-1, 0}],
Text[
Style["gwegwgwhhtrwhtrjrjwtud", 13,
FontFamily -> "CourierNew"], {-0.92, -2.1}, {1, 0}]
(*, grids*)
},
ImageSize -> 800], RoundingRadius -> 15]


In the second figure I also use arrows. Using the code given you can adjust whatever you want. Only as a suggestion, I changed the very small slices (0.001) in something bigger (0.005). This results in a thicker line so that one may recognize that some very small slices are present.

datAlt = {0.005, 0.005, 0.005, 1, 2, 3, 4};
fig2 = Framed[PieChart[
datAlt, SectorOrigin -> {Automatic, 1},
ColorFunction -> "Rainbow",
ImagePadding -> {{200, 200}, {20, 20}},
Epilog ->
{
Text[Style["Donut Plot", Black, Bold, 24], {0, 2.2}, {0, 0}],
(*============================*)
Text[Style[
"bbbbbbbbbbbbbbncccccccccccccccccccccn
aaaaaaaaaaaaaaaaaaaaaaa", 13,
FontFamily -> "CourierNew"], {-4.4, -0.}, {-1, 0}],
Arrow[{{-2.6, 0.0}, {-2.0, 0.0}}],
Arrow[{{-2.56, -0.22}, {-2.1, -0.05}}],
(*============================*)
FontFamily -> "CourierNew"], {-2.4, 0.8}, {1, 0}],
(*============================*)
Text[Style["afsafasfasfasfasfsafsab", 13,
FontFamily -> "CourierNew"], {-1.7, 1.8}, {1, 0}],
Arrow[{{-1.65, 1.8}, {-1.2, 1.6}}],
(*============================*)
Text[Style["casfasfafsafsafsafsa", 13,
FontFamily -> "CourierNew"], {2.3, 0.7}, {-1, 0}],
Arrow[{{2.25, 0.65}, {1.95, 0.5}}],
(*============================*)
Text[Style["gwegwgwhhtrwhtrjrjwtud", 13,
FontFamily -> "CourierNew"], {-1.7, -2.1}, {0, 0}],
Arrow[{{-1.7, -2.}, {-1.3, -1.5}}]
(*============================*)
(*, grids*)
},
ImageSize -> 800], RoundingRadius -> 15]


Answered by Gommaire on August 23, 2020

## Related Questions

### How to store outputs as coordinates and use ListPlot to plot them?

1  Asked on March 1, 2021 by notsotrivial

### Drawing evenly spaced arrows and opaque sheet between curves?

2  Asked on March 1, 2021 by ztan

### Varied PlotRange for plots combined using Show

3  Asked on February 28, 2021 by bulat

### Updated notebook on Mathematica online, but Chrome still shows old version

0  Asked on February 28, 2021

### How can I set a certain predicate for the result of a function to true?

2  Asked on February 28, 2021 by ng98

### Help with a custom coordinate transformation

0  Asked on February 28, 2021 by xaxa

### How to get Callout and Text[…,Offset[…]] to use the same coordinate system in Mathematica 12?

0  Asked on February 28, 2021

### Resource management in Mathematica

5  Asked on February 28, 2021

### Interactively extracting arbitrary portion of elements from a 2D list

1  Asked on February 28, 2021 by wkong

### Pattern Matching BlankSequence

1  Asked on February 27, 2021

### Symbolically prove that two expressions are identical

2  Asked on February 27, 2021

### how to get [ ] in the axis title?

0  Asked on February 27, 2021 by zoey

### Join sublists on condition

2  Asked on February 27, 2021 by istvn-zachar

### Mathematica Kernels and CPU cores

0  Asked on February 27, 2021

### Simultaneous fitting of two function with two data sets with same set of parameters

0  Asked on February 27, 2021

### Integrating piecewise function on an range

1  Asked on February 27, 2021

### ResetDirectory causes a fail on stored file names

1  Asked on February 26, 2021

### Arrow head halfway along parametric plot

2  Asked on February 26, 2021 by colin

### Intersection of 3 circles in GeometricScene

1  Asked on February 26, 2021 by sorins

### How to solve this system of coupled partial differential equations

0  Asked on February 26, 2021 by gabri