首页 文章

增加Plots.jl中子图之间的空间

提问于
浏览
3

如何增加Plots.jl中子图之间的空间?

最小的非工作示例:

julia> using Plots; pyplot()
Plots.PyPlotBackend()

julia> data = [rand(100), rand(100)];
       histogram(data, layout=2, title=["Dataset A" "Dataset B"], legend=false)
       ylabel!("ylabel")

如果使图形足够小,则第二个图形的y标签会与第一个图形发生碰撞 .

1 回答

  • 5

    Plots.jl 文档的attributes部分中,有一个名为 Subplot 的部分 . 在那里,你会找到可能对你有用的关键字 margintop_marginbottom_marginleft_marginright_margin .

    最小的工作示例是:

    using Plots, Measures
    pyplot()
    
    data = [rand(100), rand(100)];
    
    histogram(data, layout = 2,
              title = ["Dataset A" "Dataset B"], legend = false,
              ylabel = "ylabel", margin = 5mm)
    

    顺便提一下,请注意 using Measures 部分 . 我希望这有帮助 .

相关问题