【问题标题】:How to create a figure where one axis is placed between and under 2 aligned axes?如何创建一个轴位于 2 个对齐轴之间和下方的图形?
【发布时间】:2022-07-03 16:02:27
【问题描述】:

我想创建一个布局如下图所示的图形。理想情况下,所有轴必须具有相同的尺寸(对不起,我的绘画技巧不是很好)。

我找到了以下教程:https://matplotlib.org/stable/tutorials/intermediate/arranging_axes.html,但解决方案似乎很复杂。我想知道是否有更简单的方法来做到这一点。

提前致谢。

【问题讨论】:

    标签: python matplotlib customization axes


    【解决方案1】:

    可以说,实现这一目标的最简单方法是使用GridSpec

    import matplotlib.pyplot as plt
    from matplotlib.gridspec import GridSpec
    
    gs = GridSpec(3, 4)
    fig = plt.figure(tight_layout=True)
    ax1 = fig.add_subplot(gs[0, :2])
    ax2 = fig.add_subplot(gs[0, 2:])
    ax3 = fig.add_subplot(gs[1, :2])
    ax4 = fig.add_subplot(gs[1, 2:])
    ax5 = fig.add_subplot(gs[2, 1:-1])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-30
      • 1970-01-01
      • 2021-11-09
      • 2011-07-13
      • 1970-01-01
      • 2018-11-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多