Reputation: 323
Assume my Julia code is
using Plots
t = -π:1e-4:π
y = sin.(t)
plot(t,y,lw=3,legend=false)
plot!(xticks=([-π/2],["(-\\pi)/2"]))
where I want to show the parenthesis in the numerator of xticks' label while keeping its "rational" form, i.e., I don't want the numerator and the denominator to be inline. The output of the above code looks like this
One may see that the xticks' label does not include the desired parenthesis.
Here is another code to show the above function:
using Plots
t = -π:1e-4:π
y = sin.(t)
plot(t,y,lw=3,color=2,legend=false)
plot!(xticks=([-π/2],["(-π)/2"]))
which as it can be seen, the only difference with the former is in the xticks' label (in the former it is \\pi
while in the latter it is π
).
Now the picture looks like this:
which does not show the label in the "rational" form, i.e., both numerator and the denominator are inline which is undesired. Is there any way to overcome this issue?
Upvotes: 1
Views: 2852
Reputation: 42194
Try 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}"]))
Upvotes: 3