增加Plots.jl中图例标签之间的间距/填充

问题描述

我在GR后端使用Plots.jl在JuliaLang中生成一些图。我注意到,当使用LaTeXStrings.jl在图例标签生成Latex字符串时,这些标签会靠在一起。为了说明我的意思,我编辑了JuliaPlots linestyle example以在图例标签中使用Latex字符串。代码如下:

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")

上面的代码产生以下图:

Plots.jl with LaTeXStrings in the legend

如您所见,一个标签的下标与紧邻其正下方的标签的上标非常接近。对于图例标题也是如此。

我想增加每个标签间的间距/填充,以使每个标签的上标和下标之间没有间隙,但是不知道该怎么做。

解决方法

更高级的图例格式似乎仅适用于pyplot()后端。 但是,在使用gr()时,我有时会使用这个非常丑陋的技巧:

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)

enter image description here