4

我使用以下图创建了mpl_toolkits.axes_grid1

在此处输入图像描述

但是,出于某种原因,我的子情节标题没有出现。我该如何解决这个问题?

代码:

# import 
from mpl_tookits.axes_grid1 import ImageGrid
from matplotlib.pyplot import *

fig = figure(figsize=(20, 12), dpi=300)
grid = ImageGrid(fig, 111, nrows_ncols=(3, 4), axes_pad=1, aspect=False)
for gridax, (i, sub) in zip(grid, enumerate(eyelink_data)):
    subnum = i + start_with

     # format data
    xdat = sub['x'][(sub['in_trl'] == True) & (sub['x'].notnull()) & (sub['y'].notnull())]
    ydat = sub['y'][(sub['in_trl'] == True) & (sub['x'].notnull()) & (sub['y'].notnull())]

    # plot
    gridax.hist2d(xdat, ydat, bins=[np.linspace(-.005, .005, num=1000), np.linspace(-.005, .005, num=1000)])
    gridax.plot(0, 0, 'ro')  # origin

    title('Subject {0} in-Trial Gaze'.format(subnum))
    xlabel('Horizontal Offset\n(degrees visual angle)')
    ylabel('Vertical Offset\n(degrees visual angle)')

show()

PS:享受网格错觉

4

1 回答 1

5

如果您想要每个子图的标题,您可以使用该轴的标题命令。你在哪里:

title('Subject {0} in-Trial Gaze'.format(subnum))

写吧:

gridax.set_title('Subject {0} in-Trial Gaze'.format(subnum))

如果你想要一个大的xlabeland ylabel,你必须axes在你的网格周围制作一个大的对象。我不是专家,但这应该会有所帮助:

带有一个轴标签的多个子图

于 2013-03-16T02:18:25.740 回答