How can I wrap text around a circle?
For example: the text in the sectors of this chord plot.
Perhaps one could use FilledCurve[]
and then apply a GeometricTransformation[]
?
Answer
The following response borrows shamelessly from Mr.Wizard:
Manipulate[
Graphics[{{Dashed, If[circle, Circle[{0, 0}, r], {}]},
Rotate[MapThread[
Rotate[Text[Style[#, FontFamily -> "Courier", fs], #2],
90° - #3] &, {txt, {-r Cos[#], r Sin[#]} & /@ (range =
Range[0, arc, arc/(Length@txt - 1)]), range}], θ, {0,
0}]},
ContentSelectable -> True,
PlotRange -> 3,
PlotRangePadding -> .5,
ImageSize -> {500, 400}, Axes -> axes],
{{fs, 20, "font size"}, 5, 50, Appearance -> "Labeled"},
{{r, 2, "radius"}, 0.1, 3, Appearance -> "Labeled"},
{{arc, 2.5, "arc length"}, 0, 2 π, Appearance -> "Labeled"},
{{θ, 0, "location on arc"}, 0, 2 π},
{{circle, True}, {True, False}},
{{axes, True}, {True, False}},
Initialization :> {txt = "This is some text to wrap" // Characters;}
]
Note: "Arc length" is based on the unit circle. $2 \pi$, or approximately 6.28 corresponds to a $360^\circ$ arc on the unit circle. The actual full arc length will be $2\pi r$.
Comments
Post a Comment