I am using Plots.jl with the GR backend to produce some plots in JuliaLang. I have noticed that when using LaTeXStrings.jl to produce Latex strings in the legend labels that the labels are close together. To illustrate what I'm referring to, I've edited the JuliaPlots linestyle example to use Latex strings in the legend labels. The code is as follows:
using Plots; gr()
using LaTeXStrings
styles = filter((s->begin
s in Plots.supported_styles()
end), [:solid, :dash, :dot, :dashdot, :dashdotdot])
styles = reshape(styles, 1, length(styles))
n = length(styles)
y = cumsum(randn(20, n), dims = 1)
plot(y, line = (5, styles), label = [L"s^{ol}_{id}" L"d^{as}_h" L"d^{o}_{t}" L"d^{ash}_{dot}" L"dash^{dot}_{dot}"], legendtitle = "linestyle")
The above code produces the following plot:
As you can see, the subscripts of one label are very close to the superscripts of the label directly beneath. Similarly for the legend title.
I would like to increase the spacing/padding between each label so there is a gap between the super- and sub-scripts of each label, but have no idea how to do it.
More advanced legend formatting seems to be available only for pyplot()
backend.
However, when working with gr()
I sometimes use this very ugly trick:
plot(y, line = (5, styles), label = [L"^{s^{ol}_{id}}" L"^{d^{as}_h}" L"^{d^{o}_{t}}" L"^{d^{ash}_{dot}}" L"^{dash^{dot}_{dot}}"],legendtitle = "linestyle",legendfontsize=14.0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With