【问题标题】:Is there a MatLab equivalent of Python matplotlib's tight_layout()?是否有与 Python matplotlib 的tight_layout() 等效的 MatLab?
【发布时间】:2021-04-22 13:44:38
【问题描述】:

我发现普通 Python Matplotlib 和 Matlab 中的绘图周围的空白数量非常烦人,特别是当将保存的(横向)图形插入标准(纵向).doc 或.pdf 文件。

幸运的是,Python Matplotlib 具有“tight_layout()”功能,可以很好地处理这个问题。 Matlab 是否有类似的简单、单一解决方案通用的方法?

我知道有多种方法可以减少 Matlab 中绘图的边距(例如 this 用于子图,或 thisthis 用于 pdf 输出),但我似乎找不到一个包罗万象的“最小化空白量”功能,如 Python 的tight_layout()。

【问题讨论】:

    标签: python matlab matplotlib plot matlab-figure


    【解决方案1】:

    您可以使用 Matlab R2019b 中引入的 tiledlayout 来实现这一点。要减少空格,您可以使用'TileSpacing''Padding' 参数,其值可以是'compact''none'

    h = tiledlayout(2,2, 'TileSpacing', 'none', 'Padding', 'none');
    nexttile
    plot(1:4, rand(1,4))
    nexttile
    plot(1:8, rand(1,8))
    nexttile
    plot(1:16, rand(1,16))
    nexttile
    plot(1:32, rand(1,32))
    

    【讨论】:

    • 特别是TileSpacing 选项
    • @user1543042 谢谢!我举了一个例子
    • 太棒了!这也适用于将其用作单个平铺图,如下所示:h = tiledlayout(1,1, 'TileSpacing', 'none', 'Padding', 'none'); nexttile plot(1:4, rand(1,4)) 这正是我想要的。谢谢@LuisMendo
    • @RobH。很高兴我能帮上忙!
    猜你喜欢
    • 2011-06-06
    • 1970-01-01
    • 2018-10-14
    • 1970-01-01
    • 2014-08-05
    • 1970-01-01
    • 2013-02-04
    • 2012-11-21
    • 2016-10-20
    相关资源
    最近更新 更多