我的目标是在每组4个子图周围放置一个边界框。我似乎无法弄清楚如何使用我的gridspec子图。我遇到的示例是指单个子图,而不是整个gridspec。
(我选择使用gridspec进行这样的绘制,以便可以控制子图组之间的间距)
from matplotlib import pyplot as plt
import matplotlib.gridspec as gridspec
fig = plt.figure(figsize=(16,16))
fig.suptitle(' title ', fontsize=12,
bbox={'facecolor':'none', 'alpha':0.5, 'pad':5})
gs = gridspec.GridSpec(2, 2)
gs.update(top=.48,left=0.1, right=0.48, wspace=0.15,hspace=0.2)
ax1 = plt.subplot(gs[0])
ax1.set_title('axes title')
ax2 = plt.subplot(gs[1])
ax2.set_title('axes title')
ax3 = plt.subplot(gs[2])
ax3.set_title('axes title')
ax4 = plt.subplot(gs[3])
ax4.set_title('axes title')
#New Gridspec
gs1 = gridspec.GridSpec(2, 2)
gs1.update(bottom=.53,left=0.55, right=0.9, hspace=0.2, wspace=.15)
ax5 = plt.subplot(gs1[0])
ax5.set_title('axes title')
ax6 = plt.subplot(gs1[1])
ax6.set_title('axes title')
ax7 = plt.subplot(gs1[2])
ax7.set_title('axes title')
ax8 = plt.subplot(gs1[3])
ax8.set_title('axes title')
#New …Run Code Online (Sandbox Code Playgroud)