Линия
Добавление строки так же просто, как
line = plt.Line2D((.5,.5),(.1,.9), color="k", linewidth=3)
fig.add_artist(line)

import matplotlib.pyplot as plt
import numpy as np
a = np.random.rand(10,10,8)
columns = 4
rows = a.shape[2]//columns
fig, axarr = plt.subplots(rows, columns)
fig.subplots_adjust(left=0.1, right=0.9, wspace=0.4)
for i, ax in enumerate(axarr.flat):
img = a[:,:,i]
ax.imshow(img)
ax.set_title("-Patch {}".format(i))
line = plt.Line2D((.5,.5),(.1,.9), color="k", linewidth=3)
fig.add_artist(line)
plt.show()
Более сложное решение с линиями см. В Нарисуйте разделитель или линии между вспомогательными участками
Пробел
Тем не менее, потенциально вы бы предпочли отрегулировать расстояние между графиками.
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
import numpy as np
a = np.random.rand(10,10,8)
columns = 4
rows = a.shape[2]//columns
fig = plt.figure()
axarr1 = fig.subplots(2,2, gridspec_kw=dict(left=0.05, right=0.43, wspace=0.4))
axarr2 = fig.subplots(2,2, gridspec_kw=dict(left=0.57, right=0.95, wspace=0.4))
for i, ax in enumerate(axarr1.flat):
img = a[:,:,i]
ax.imshow(img)
ax.set_title("-Patch {}".format(i))
for i, ax in enumerate(axarr2.flat):
img = a[:,:,i+4]
ax.imshow(img)
ax.set_title("-Patch {}".format(i+4))
plt.show()
Это позволяет визуально разделить две группы вспомогательных участков без какой-либо черной линии на графике.
