MEH*_*TAY 8 python matplotlib subplot
我试图消除两个特定轴之间的垂直空间;然而plt.figure(layout='constrained')
阻止matplotlib.pyplot.subplots_adjust(hspace=0)
。
layout='constrained'
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(10, 8),layout='constrained')
# fig = plt.figure(figsize=(10, 8))
subfigs = fig.subfigures(2, 1)
axsUp = subfigs[0].subplots(1, 3)
subfigsnest = subfigs[1].subfigures(1, 2, width_ratios=[1, 2])
ax = subfigsnest[0].subplots(1)
axsnest = subfigsnest[1].subplots(2, 1, sharex=True)
subfigsnest[1].subplots_adjust(hspace=0)
plt.show()
Run Code Online (Sandbox Code Playgroud)
layout='constrained'
import matplotlib.pyplot as plt
# fig = plt.figure(figsize=(10, 8),layout='constrained')
fig = plt.figure(figsize=(10, 8))
subfigs = fig.subfigures(2, 1)
axsUp = subfigs[0].subplots(1, 3)
subfigsnest = subfigs[1].subfigures(1, 2, width_ratios=[1, 2])
ax = subfigsnest[0].subplots(1)
axsnest = subfigsnest[1].subplots(2, 1, sharex=True)
subfigsnest[1].subplots_adjust(hspace=0)
plt.show()
Run Code Online (Sandbox Code Playgroud)
使用subplots_adjust(hspace=0)
withlayout='constrained'
不起作用,它会产生警告UserWarning:该图使用了与 subplots_adjust 和/或ight_layout 不兼容的布局引擎;不调用 subplots_adjust。。