def align_subplot_array(axes,xlim=None, ylim=None):
<EOL>if xlim is None:<EOL><INDENT>xlim = [np.inf,-np.inf]<EOL>for ax in axes.flatten():<EOL><INDENT>xlim[<NUM_LIT:0>] = min(xlim[<NUM_LIT:0>],ax.get_xlim()[<NUM_LIT:0>])<EOL>xlim[<NUM_LIT:1>] = max(xlim[<NUM_LIT:1>],ax.get_xlim()[<NUM_LIT:1>])<EOL><DEDENT><DEDENT>if ylim is None:<EOL><INDENT>ylim = [np.inf,-np.inf]<EOL>for ax in axes.flatten():<EOL><INDENT>ylim[<NUM_LIT:0>] = min(ylim[<NUM_LIT:0>],ax.get_ylim()[<NUM_LIT:0>])<EOL>ylim[<NUM_LIT:1>] = max(ylim[<NUM_LIT:1>],ax.get_ylim()[<NUM_LIT:1>])<EOL><DEDENT><DEDENT>N,M = axes.shape<EOL>for i,ax in enumerate(axes.flatten()):<EOL><INDENT>ax.set_xlim(xlim)<EOL>ax.set_ylim(ylim)<EOL>if (i)%M:<EOL><INDENT>ax.set_yticks([])<EOL><DEDENT>else:<EOL><INDENT>removeRightTicks(ax)<EOL><DEDENT>if i<(M*(N-<NUM_LIT:1>)):<EOL><INDENT>ax.set_xticks([])<EOL><DEDENT>else:<EOL><INDENT>removeUpperTicks(ax)<EOL><DEDENT><DEDENT>
Make all of the axes in the array hae the same limits, turn off unnecessary ticks
use plt.subplots() to get an array of axes