def hist2d(x, y, bins=<NUM_LIT:10>, labels=None, aspect="<STR_LIT>", plot=True, fig=None, ax=None, interpolation='<STR_LIT:none>', cbar=True, **kwargs):
h_range   = kwargs.pop('<STR_LIT>', None)<EOL>h_normed  = kwargs.pop('<STR_LIT>', None)<EOL>h_weights = kwargs.pop('<STR_LIT>', None)<EOL>h, xe, ye = _np.histogram2d(x, y, bins=bins, range=h_range, normed=h_normed, weights=h_weights)<EOL>extent    = [xe[<NUM_LIT:0>], xe[-<NUM_LIT:1>], ye[<NUM_LIT:0>], ye[-<NUM_LIT:1>]]<EOL>if plot:<EOL><INDENT>if ax is None:<EOL><INDENT>if fig is None:<EOL><INDENT>fig = _figure('<STR_LIT>')<EOL><DEDENT>ax = fig.gca()<EOL>ax.clear()<EOL><DEDENT>img = ax.imshow(h.transpose(), extent=extent, interpolation=interpolation, aspect=aspect, **kwargs)<EOL>if cbar:<EOL><INDENT>_colorbar(ax=ax, im=img)<EOL><DEDENT>if labels is not None:<EOL><INDENT>_addlabel(labels[<NUM_LIT:0>], labels[<NUM_LIT:1>], labels[<NUM_LIT:2>])<EOL><DEDENT><DEDENT>return h, extent<EOL>
Creates a 2-D histogram of data *x*, *y* with *bins*, *labels* = :code:`[title, xlabel, ylabel]`, aspect ration *aspect*. Attempts to use axis *ax* first, then the current axis of *fig*, then the last axis, to use an already-created window.

Plotting (*plot*) is on by default, setting false doesn't attempt to create a figure.

*interpolation* sets the interpolation type of :meth:`matplotlib.axis.imshow`.

Returns a handle and extent as :code:`h, extent`