I'm having some trouble getting the labels right in a SciDraw figure. More precisely, I want labels at half-integer multiples of $\pi$, and I want them as clean inline fractions (i.e. as $\pi/2$ and not $\frac{\pi}{2}$. So far, what I've found works best is to get the numerator and denominator separately and then join them as strings,giving something like
Plot[
Cos[ωt]^2
, {ωt, -0.3, 2 π + 0.3}
, Frame -> True
, FrameTicks -> {{None, None}, {
Function[{#,
Style[
StringReplace[
ToString[Numerator[Rationalize[#/π]]] <> "π/" <>
ToString[Denominator[Rationalize[#/π]]]
, {"/1" -> "", "1π" -> "π", "0π" -> "0"}]
, FontSize -> 30
]
}] /@ Range[0, 2 π, π/2]
, None}}
]
If I do this in SciDraw, though, using the XTicks and LinTicks specifications,
Figure[
FigurePanel[{
FigGraphics[
Plot[Cos[ωt]^2, {ωt, -0.3, 2 π + 0.3}]
];
}
, XPlotRange -> {-0.3, 2 π + 0.3}
, XTicks -> LinTicks[-2 π, 2 π, π/2, 1, TickLabelFunction ->
Function[
Style[
StringReplace[
ToString[Numerator[Rationalize[#/π]]] <> "π/" <>
ToString[Denominator[Rationalize[#/π]]]
, {"/1" -> "", "1π" -> "π", "0π" -> "0"}]
, FontSize -> 30
]
]
]
]
, CanvasSize -> {5, 3}
]
the output doesn't quite look right:
In particular, note the incorrect positioning of the label at $\pi$. \[SadSmiley]
. So:
- Is there a way to get SciDraw to place these ticks correctly?
- (Why is it doing it anyway?)
- Am I barking up the wrong tree with these string replacements, i.e. is there a simpler way to produce this output?