def plot(self, metric="woe", savefig=None, save_kwargs=None):
        """Plot the binning table.

        Visualize the Weight of Evidence or the event rate for each bin as a
        matrix, and the x and y trend.

        Parameters
        ----------
        metric : str, optional (default="woe")
            Supported metrics are "woe" to show the Weight of Evidence (WoE)
            measure and "event_rate" to show the event rate.

        savefig : str or None (default=None)
            Path to save the plot figure.

        save_kwargs : dict or None (default=None)
            Additional keyword arguments to be passed to `plt.savefig`.
        """
        _check_is_built(self)

        if metric not in ("event_rate", "woe"):
            raise ValueError('Invalid value for metric. Allowed string '
                             'values are "event_rate" and "woe".')

        if metric == "woe":
            metric_values = self._woe
            metric_matrix = self._W
            metric_label = "WoE"
        elif metric == "event_rate":
            metric_values = self._event_rate
            metric_matrix = self.D
            metric_label = "Event rate"

        fig, ax = plt.subplots(figsize=(7, 7))

        divider = make_axes_locatable(ax)
        axtop = divider.append_axes("top", size=2.5, pad=0.1, sharex=ax)
        axright = divider.append_axes("right", size=2.5, pad=0.1, sharey=ax)
        # Hide x labels and tick labels for top plots and y ticks for
        # right plots.

        # Position [0, 0]
        for path in self._paths_x:
            er = sum([
                [metric_values[p]] * np.count_nonzero(
                    self.P == p, axis=1).max() for p in path], [])

            er = er + [er[-1]]
            axtop.step(np.arange(self.n + 1) - 0.5, er,
                       label=str(path), where="post")

        for i in range(self.n):
            axtop.axvline(i + 0.5, color="grey", linestyle="--", alpha=0.5)

        axtop.get_xaxis().set_visible(False)
        axtop.set_ylabel(metric_label, fontsize=12)

        # Position [1, 0]
        pos = ax.matshow(metric_matrix, cmap=plt.cm.bwr)
        for j in range(self.n):
            for i in range(self.m):
                c = int(self.P[i, j])
                ax.text(j, i, str(c), va='center', ha='center')

        fig.colorbar(pos, ax=ax, orientation="horizontal",
                     fraction=0.025, pad=0.125)

        ax.xaxis.set_label_position("bottom")
        ax.xaxis.tick_bottom()
        ax.set_xlabel("Bin ID - x ({})".format(self.name_x), fontsize=12)
        ax.set_ylabel("Bin ID - y ({})".format(self.name_y), fontsize=12)

        # Position [1, 1]
        for path in self._paths_y:
            er = sum([
                [metric_values[p]] * (np.count_nonzero(
                    self.P == p, axis=0).max()) for p in path], [])

            er = er + [er[-1]]
            axright.step(er, np.arange(self.m + 1) - 0.5, label=str(path),
                         where="pre")

        for j in range(self.m):
            axright.axhline(j - 0.5, color="grey", linestyle="--", alpha=0.5)

        axright.get_yaxis().set_visible(False)
        axright.set_xlabel(metric_label, fontsize=12)

        # adjust margins
        axright.margins(y=0)
        axtop.margins(x=0)
        plt.tight_layout()

        axtop.legend(bbox_to_anchor=(1, 1))
        axright.legend(bbox_to_anchor=(1, 1))

        if savefig is None:
            plt.show()
        else:
            if not isinstance(savefig, str):
                raise TypeError("savefig must be a string path; got {}."
                                .format(savefig))
            if save_kwargs is None:
                save_kwargs = {}
            else:
                if not isinstance(save_kwargs, dict):
                    raise TypeError("save_kwargs must be a dictionary; got {}."
                                    .format(save_kwargs))
            plt.savefig(savefig, **save_kwargs)
            plt.close()
Plot the binning table.

        Visualize the Weight of Evidence or the event rate for each bin as a
        matrix, and the x and y trend.

        Parameters
        ----------
        metric : str, optional (default="woe")
            Supported metrics are "woe" to show the Weight of Evidence (WoE)
            measure and "event_rate" to show the event rate.

        savefig : str or None (default=None)
            Path to save the plot figure.

        save_kwargs : dict or None (default=None)
            Additional keyword arguments to be passed to `plt.savefig`.
        
optbinning/binning/multidimensional/binning_statistics_2d.py