1
$\begingroup$

Say

counts = {0.18, 0.51, 0.31};

PieChart[counts, ChartLabels -> counts, PlotRange -> All,   Frame -> True, FrameTicks -> None]

I am completely puzzled how can I achieve a format like that of the following Figure.

enter image description here

$\endgroup$
2
  • $\begingroup$ Are you just interested in reproducing the figure, or do you need to do this programmatically for a number of data sets? $\endgroup$
    – MarcoB
    Commented Feb 9, 2019 at 21:22
  • $\begingroup$ @MarcoB I want to do for other data sets as well. But instead of describing what I want, I thought it was a better idea to provide this figure as a guideline. (Thanks for your comment) $\endgroup$
    – Dimitris
    Commented Feb 9, 2019 at 21:27

1 Answer 1

4
$\begingroup$
counts = {0.18, 0.51, 0.31};
n = 600;
labels = Placed[Row /@ Thread[{Quantity[Round[100 counts], "Percent"], 
    " (" <> ToString@# <> "H)" & /@ Round[ n counts]}], "RadialOutside"];
legend = Placed[SwatchLegend[Automatic, Row /@ Thread[{{"CM ", "TD ", "TP "}, 
    Row[{"(", #, ")"}] & /@ Quantity[Round[100 counts], "Percent"]}]], 
   {After, Bottom}, Framed];

Framed[PieChart[counts, ChartLabels -> labels, ChartLegends -> legend, PlotRange -> All]]

enter image description here

$\endgroup$
5
  • $\begingroup$ Thank you for your answer! Exactly what I wanted. Just a question, How can I modify the associated text (in legend and in pie chart) show that it appears with the following option Style["x", FontSize -> 12, FontFamily -> "Latin Modern Roman", FontColor -> Black] where "x", e.g. 18% (108H) or CM (18%) and so on. $\endgroup$
    – Dimitris
    Commented Feb 10, 2019 at 12:23
  • 1
    $\begingroup$ @dimitris, you can add the option LabelStyle -> {FontSize -> 12, FontFamily -> "Latin Modern Roman", FontColor -> Black} to SwatchLegend. $\endgroup$
    – kglr
    Commented Feb 10, 2019 at 12:28
  • $\begingroup$ Thanks for your quick feedback. It works as desired but this affects only the associated SwatchLegend. I want also to affect accordingly the associated text that accompanies each pie. $\endgroup$
    – Dimitris
    Commented Feb 10, 2019 at 12:33
  • 1
    $\begingroup$ @dimitris, add the same option to PieChart. $\endgroup$
    – kglr
    Commented Feb 10, 2019 at 12:39
  • $\begingroup$ Perfect! Thanks a lot. $\endgroup$
    – Dimitris
    Commented Feb 10, 2019 at 12:57

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.