我正在使用带有 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")
上面的代码产生以下图:如您所见,一个标签的下标与正下方标签的上标非常接近。与图例标题类似。
我想增加每个标签之间的间距/填充,因此每个标签的 super 脚本和子脚本之间存在间隙,但不知道该怎么做。
最佳答案
更高级的图例格式似乎仅适用于 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)
关于julia - 增加 Plots.jl 中图例标签之间的间距/填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64466370/