2
$\begingroup$

I am using the following code to produce the graph below. I would like to modify its ChartLabels so they appear only for the outermost layer.

data = {{"Benefit_type", "IP", "OP", "OPT", "DNT", 
    "MTR"}, {"older_earned_net_premium", 134., 223., 345., 234., 
    234.}, {"previous_earned_net_premium", 54., 175., 235., 234., 
    123.}};

PieChart[
        #[[2 ;;, 2 ;;]]/(Plus @@@ (#[[2 ;;, 2 ;;]]))*100,
        LabelingFunction -> (Placed[Row[{NumberForm[#, {3, 1}], "%"}], 
       "RadialCenter"] &),
        ChartLabels -> Placed[#[[1, 2 ;;]], "RadialCallout"],
        LabelStyle -> FontSize -> 12,
        PlotTheme -> "Detailed",
        ImageSize -> Large
    ] &@data

enter image description here

$\endgroup$
  • $\begingroup$ Could you provide the reproducable code? $\endgroup$ – ercegovac Oct 6 '17 at 10:36
  • $\begingroup$ I have added the reproducible code. $\endgroup$ – user13892 Oct 6 '17 at 10:44
2
$\begingroup$

Wrap the last dataset with Labeled and remove ChartLabels:

Module[{d = 100 Normalize[#, Total] & /@ #[[2 ;;, 2 ;;]], labels = #[[1, 2 ;;]]}, 
   d[[-1]] = Thread[Labeled[d[[-1]], labels, "RadialCallout"]]; 
   PieChart[d, 
     LabelingFunction -> (Placed[Row[{NumberForm[#, {3, 1}], "%"}], "RadialCenter"] &), 
     LabelStyle -> FontSize -> 12, ImageSize -> Large]] &@data

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Although i needed it to work for any number of data layers not just two but using Slot function i was able to generalize your solution. Thank you! $\endgroup$ – user13892 Oct 6 '17 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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