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

标签 julia 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
如您所见,一个标签的下标与正下方标签的上标非常接近。与图例标题类似。
我想增加每个标签之间的间距/填充,因此每个标签的 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)
enter image description here

关于julia - 增加 Plots.jl 中图例标签之间的间距/填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64466370/

相关文章:

julia - 别名元组类型时的额外内存分配

function - Julia 在调用之前覆盖函数

julia - 利用 Julia 的集成能力

julia - 使用 Plots.jl 对多个绘图进行着色

julia - 带有 plots.jl 的误差条的颜色

julia - 如何在 julia Plots 中更改图形图例中的线宽?

c - 如何在 Julia 中使用/创建更通用的 ccall?

bytecode - 当我们运行 julia-lang 脚本时会发生什么?

plot - 如何使用 Plots.jl 根据 z 中的值为 (x,y) 散点图着色?

julia - 如何在 Plots.jl 中标记条形图?