Julia Plots 中的 xticks 标签格式

xticks' labels formatting in Julia Plots

假设我的 Julia 代码是

using Plots

t = -π:1e-4:π
y = sin.(t)
plot(t,y,lw=3,legend=false)
plot!(xticks=([-π/2],["(-\pi)/2"]))

想在 xticks 标签的分子中显示括号,同时保持其“有理”形式,即,我不希望分子和分母是内联的。上面代码的输出看起来像这样

可能会看到 xticks 的标签不包含所需的括号。

这是显示上述功能的另一个代码:

using Plots

t = -π:1e-4:π
y = sin.(t)
plot(t,y,lw=3,color=2,legend=false)
plot!(xticks=([-π/2],["(-π)/2"]))

由此可见,与前者唯一的区别在于xticks的标签(前者是\pi,后者是π)。 现在图片是这样的:

不以“有理”形式显示标签,即分子和分母都是内联的,这是不希望的。有什么办法可以解决这个问题吗?

尝试 using LaTeXStrings:

using Plots
using LaTeXStrings
gr()
t = -π:1e-4:π
y = sin.(t)
plot(t,y,lw=3,legend=false)
plot!(xticks=([-π/2],[L"\frac{(-\pi)}{2}"]))