8
$\begingroup$

I know how to add Callouts to the outside of a PieChart, but I would like to add inner ticks like this:

enter image description here

Note the 3, 6, 9, 12 ticks in the above image. Are there any simple options that I'm missing? Can ticks and inner callouts both be set?

Here's a MWE:

PieChart[{3, 4, 2, 3, 2}, SectorOrigin -> {Automatic, 2},
 PlotRangePadding -> -10, ImagePadding -> -20, Frame -> False, 
 ImageMargins -> -10,
 ChartLabels -> Placed[{"1", "2", "3", "4", "5"}, "RadialCallout"]]

enter image description here

$\endgroup$

1 Answer 1

9
$\begingroup$
ticks = Join[Thread[{Range[π/2, 2 π, π/2], Reverse@Range[3, 12, 3], 
     {0, .05}}, List, 2], 
   Thread[{Complement[Range[π/6, 2 π- π/6, π/6], Range[π/2, 2 π, π/2]], "",
     {0, .02}}, List, 1]];
pc2 = First @ PieChart[{1, 1}, SectorOrigin -> {{0, 1}, 2}, 
   ChartStyle -> Directive[EdgeForm[], FaceForm[None]], 
   SectorSpacing -> {0, 0}, PerformanceGoal -> "Speed", 
   PolarAxes -> True, PolarTicks -> {ticks, None}, 
   PolarAxesOrigin -> {0, 1/10000}];
axis = pc2 /. t_Text :> (t /. Scaled[{0., 0.}, a_] :> Scaled[-.05 a, a]);

opts = Sequence[SectorOrigin -> {Automatic, 2}, PlotRangePadding -> -10, 
   ImagePadding -> -20, Frame -> False, ImageMargins -> -10, 
   BaseStyle -> {FontSize -> Scaled[.04]}];
PieChart[{3, 4, 2, 3, 2}, opts, 
 ChartLabels -> Placed[{"1", "2", "3", "4", "5"}, "RadialCallout"], 
 Epilog -> axis]

enter image description here

A more convenient approach is to use ClockGauge to create an angular axis:

ClearAll[angularAxis]
angularAxis[o:OptionsPattern[]][so_, t_: Range[3, 12, 3], tl_: {20, 12}, sd_: {12, 5}] :=
  {First[ClockGauge[{}, ScaleOrigin -> so, ScaleDivisions -> sd, o, "TickLengths" -> tl, 
      GaugeMarkers -> None, GaugeFrameStyle -> Directive[EdgeForm[], White], 
      TicksStyle -> {Thick, Thin}, LabelStyle -> FontSize -> Scaled[.03]] /. 
    Text[a_, b___] :> Text[a /. Except[Alternatives @@ t] :> "", b]], 
   Circle[{0, 0}, so]};

PieChart[{3, 4, 2, 3, 2}, opts, 
 ChartLabels -> Placed[{"1", "2", "3", "4", "5"}, "RadialCallout"], 
 ImageSize -> Large, Epilog -> angularAxis[][2]]

enter image description here

Use

angularAxis["LabelSide"->Right, "TickSide"->Left, TicksStyle->Directive[Thin, Black]][2]

to get

enter image description here

and

Epilog -> angularAxis["LabelSide" -> Right, "TickSide" -> Left][1.5]

to get

enter image description here

$\endgroup$

Your Answer

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

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