对于下面的MWE,我使用在this docs page中定义的函数.请考虑以下代码:

import matplotlib.pyplot as plt
import numpy as np


# Helper function used for visualization in the following examples
def identify_axes(ax_dict, fontsize=48):
    """
    Helper to identify the Axes in the examples below.

    Draws the label in a large font in the center of the Axes.

    Parameters
    ----------
    ax_dict : dict[str, Axes]
        Mapping between the title / label and the Axes.
    fontsize : int, optional
        How big the label should be.
    """
    kw = dict(ha="center", va="center", fontsize=fontsize, color="darkgrey")
    for k, ax in ax_dict.items():
        ax.text(0.5, 0.5, k, transform=ax.transAxes, **kw)

axd = plt.figure(layout="constrained").subplot_mosaic(
    """
    AC
    DD
    """
)
identify_axes(axd)

这就产生了这个数字:

enter image description here Basically I'm trying to reproduce something like this figure:

我的问题是:我如何才能产生一个类似的图形,但底部的情节与其他两个具有相同的大小,并且仍然居中?不管怎么说,我都想不出这一点.

推荐答案

import matplotlib.pyplot as plt

axd = plt.figure(layout="constrained").subplot_mosaic(
    """
    AABB
    .CC.
    """
)
plt.show()

enter image description here

Python相关问答推荐

ambda将时间戳与组内另一列的所有时间戳进行比较

如何在Python中使用时区夏令时获取任何给定本地时间的纪元值?

如何通过多2多字段过滤查询集

用gekko解决的ADE方程系统突然不再工作,错误消息异常:@错误:模型文件未找到.& &

TARete错误:类型对象任务没有属性模型'

SQLGory-file包FilField不允许提供自定义文件名,自动将文件保存为未命名

Matlab中是否有Python的f-字符串等效物

当使用keras.utils.Image_dataset_from_directory仅加载测试数据集时,结果不同

带条件计算最小值

处理(潜在)不断增长的任务队列的并行/并行方法

Mistral模型为不同的输入文本生成相同的嵌入

加速Python循环

无法定位元素错误404

在单次扫描中创建列表

ruamel.yaml dump:如何阻止map标量值被移动到一个新的缩进行?

OpenGL仅渲染第二个三角形,第一个三角形不可见

从旋转的DF查询非NaN值

以异步方式填充Pandas 数据帧

如何在GEKKO中使用复共轭物

504未连接IB API TWS错误—即使API连接显示已接受''