<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def plot_posterior( data, var_names=None, coords=None, figsize=None, textsize=None, credible_interval=0.94, round_to=1, point_estimate="mean", rope=None, ref_val=None, kind="kde", bw=4.5, bins=None, ax=None, **kwargs ):
 """Plot Posterior densities in the style of John K. Kruschke's book. Parameters data : obj Any object that can be converted to an az.InferenceData object Refer to documentation of az.convert_to_dataset for details var_names : list of variable names Variables to be plotted, two variables are required. coords : mapping, optional Coordinates of var_names to be plotted. Passed to `Dataset.sel` figsize : tuple Figure size. If None it will be defined automatically. textsize: float Text size scaling factor for labels, titles and lines. If None it will be autoscaled based on figsize. credible_interval : float, optional Credible intervals. Defaults to 0.94. round_to : int Controls formatting for floating point numbers point_estimate: str Must be in ('mode', 'mean', 'median') rope: tuple or dictionary of tuples Lower and upper values of the Region Of Practical Equivalence. If a list is provided, its length should match the number of variables. ref_val: float or dictionary of floats display the percentage below and above the values in ref_val. If a list is provided, its length should match the number of variables. kind: str Type of plot to display (kde or hist) For discrete variables this argument is ignored and a histogram is always used. bw : float Bandwidth scaling factor for the KDE. Should be larger than 0. The higher this number the smoother the KDE will be. Defaults to 4.5 which is essentially the same as the Scott's rule of thumb (the default rule used by SciPy). Only works if `kind == kde`. bins : integer or sequence or 'auto', optional Controls the number of bins, accepts the same keywords `matplotlib.hist()` does. Only works if `kind == hist`. If None (default) it will use `auto` for continuous variables and `range(xmin, xmax + 1)` for discrete variables. ax : axes Matplotlib axes. Defaults to None. **kwargs Passed as-is to plt.hist() or plt.plot() function depending on the value of `kind`. Returns ------- ax : matplotlib axes Examples -------- Show a default kernel density plot following style of John Kruschke .. plot:: :context: close-figs Plot subset variables by specifying variable name exactly .. plot:: :context: close-figs Plot Region of Practical Equivalence (rope) for all distributions .. plot:: :context: close-figs Plot Region of Practical Equivalence for selected distributions .. plot:: :context: close-figs Add reference lines .. plot:: :context: close-figs Show point estimate of distribution .. plot:: :context: close-figs Plot posterior as a histogram .. plot:: :context: close-figs Change size of credible interval .. plot:: :context: close-figs """

    data = convert_to_dataset(data, group="posterior")
    var_names = _var_names(var_names, data)

    if coords is None:
        coords = {}

    plotters = list(xarray_var_iter(get_coords(data, coords), var_names=var_names, combined=True))
    length_plotters = len(plotters)
    rows, cols = default_grid(length_plotters)

    (figsize, ax_labelsize, titlesize, xt_labelsize, _linewidth, _) = _scale_fig_size(
        figsize, textsize, rows, cols
    )
    kwargs.setdefault("linewidth", _linewidth)

    if ax is None:
        _, ax = _create_axes_grid(
            length_plotters, rows, cols, figsize=figsize, squeeze=False, constrained_layout=True
        )

    for (var_name, selection, x), ax_ in zip(plotters, np.ravel(ax)):
        _plot_posterior_op(
            x.flatten(),
            var_name,
            selection,
            ax=ax_,
            bw=bw,
            bins=bins,
            kind=kind,
            point_estimate=point_estimate,
            round_to=round_to,
            credible_interval=credible_interval,
            ref_val=ref_val,
            rope=rope,
            ax_labelsize=ax_labelsize,
            xt_labelsize=xt_labelsize,
            **kwargs
        )

        ax_.set_title(make_label(var_name, selection), fontsize=titlesize, wrap=True)

    return ax