import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(10, 10), tight_layout=True)
ax.plot([-0.5, 0.6], [1, 1.35])
xlabel = ax.set_xlabel("TEST")
y = xlabel.get_window_extent().transformed(ax.transAxes.inverted()).y0
ax.text(s='TEST_position', x=0.25, y=y, transform=ax.transAxes)
文本“TEST_position”应放置在 xlabel 的相同 y 位置处。我的方法行不通。
您能详细说明一下您的问题吗?我很困惑你想要实现什么目标。