This function:
def plotGrid(ax, grid, text=''):
ax.imshow(grid, cmap=cmap, norm=Normalize(vmin=0, vmax=9))
ax.grid(True, which='both', color='lightgrey', linewidth=0.5)
ax.set_yticks([x-0.5 for x in range(1 len(grid))])
ax.set_xticks([x-0.5 for x in range(1 len(grid[0]))])
ax.set_xticklabels([])
ax.set_yticklabels([])
ax.set_title(text)
def plotTaskGrids(task):
nTrain = len(task['train'])
fig, ax = plt.subplots(2, nTrain, figsize=(3*nTrain, 3*2))
for i in range(nTrain):
plotGrid(ax[0, i], task['train'][i]['input'], 'train input')
plotGrid(ax[1, i], task['train'][i]['output'], 'train output')
plt.tight_layout()
plt.title('title')
plt.show()
displays this window:
I would like to replace Figure 1
in the window title with title
, but plt.title('title')
doesn't accomplish that, instead it changes one of the subtitles. What is the solution?
CodePudding user response:
Perhaps you could try adding num="title" when calling plt.subplots?
fig, ax = plt.subplots(2, nTrain, figsize=(3*nTrain, 3*2), num="title")
This should get passed to the plt.figure call within the subplots call.