KristofferC / PGFPlotsX.jl

Plots in Julia using the PGFPlots LaTeX package
Other
301 stars 40 forks source link

LaTeX's lower indices in the legend are not shown correctly #265

Closed zhiyuanzhai closed 3 years ago

zhiyuanzhai commented 3 years ago

For example: example

using Plots; pgfplotsx()
plot(1:20, rand(20,2), ,label=[raw"$y_1$" raw"$y_2$"], xlabel=raw"$x$", ylabel=raw"$y_i$")

The lower index in the axes shows as normal, but the ones in the legend are shown some kind of raw code instead of lower indices.

KristofferC commented 3 years ago

Looks like a bug in the Plots.jl wrapper. It seems they do some escaping, the legend entry that gets created is

julia> p = plot(1:20, label="\$y_1\$")

julia> p.o.the_plot.elements[1].elements[1].contents[end]
PGFPlotsX.LegendEntry(PGFPlotsX.Options(OrderedCollections.OrderedDict{Any, Any}(), false), "\$y\\_1\$", false)

It seems you can use LaTeXStrings to fix it:

julia> using LaTeXStrings

julia> p = plot(1:20, label=L"$y_1$")

bild

If you want to follow up on this, please report it to the Plots.jl repo.

zhiyuanzhai commented 3 years ago

It doesn't seem to work for me. I'm considering to report it to Plots.jl. Anyway, thanks!