#NEWLINE# def work_grid( grid , fig ) : #NEWLINE# #INDENT# '\n    Take a two dimensional grid, add subplots to a figure for each cell and do\n    layer work.\n\n    Parameters:\n    -----------\n    grid: a two dimensional grid of layers\n    fig: matplotlib figure to draw on\n\n    Returns:\n    --------\n    axes: a two dimensional list of matplotlib axes\n    ' #NEWLINE# nrows = len ( grid ) #NEWLINE# ncols = len ( grid [ 0 ] ) #NEWLINE# axes = [ [ None for _ in range ( ncols ) ] for _ in range ( nrows ) ] #NEWLINE# for row in range ( nrows ) : #NEWLINE# #INDENT# for col in range ( ncols ) : #NEWLINE# #INDENT# axes [ row ] [ col ] = fig . add_subplot ( nrows , ncols , ( ( ( ncols * row ) + col ) + 1 ) ) #NEWLINE# grid [ row ] [ col ] . work ( ax = nrows [ row ] [ col ] ) #NEWLINE# #UNINDENT# #UNINDENT# return axes