Beispiel #1
0
def plot_band(line_kws: Dict[str, Any] = None,
              fill_kws: Dict[str, Any] = None,
              y_min: Optional[float] = None,
              **kwargs) -> Axes:
    """Plots gvar as a band.

    Arguments:
        line_kws: Kwargs specific for line plot
        fill_kws: Kwargs specific for fill between
        y_min: Minimal value for data
        kwargs:  Shared kwargs
            Requires: x and y1, ym, y2
    """
    line_kws = line_kws.copy() or {}
    fill_kws = fill_kws.copy() or {}

    y1 = kwargs.pop("y1")
    ym = kwargs.pop("ym")
    y2 = kwargs.pop("y2")
    if y_min is not None:
        y1 = where(y1 < y_min, y_min, y1)
        ym = where(ym < y_min, y_min, ym)
    x = kwargs.pop("x")

    ax = kwargs.pop("ax", get_current_actor())

    line_kws.update(kwargs)
    fill_kws.update(kwargs)

    ax.plot(x, ym, **line_kws)
    ax.fill_between(x, y1, y2, **fill_kws)

    return ax
Beispiel #2
0
def plot_band(
    line_kws: Dict[str, Any] = None, fill_kws: Dict[str, Any] = None, **kwargs
) -> Axes:
    """Plots gvar as a band.

    Arguments:
        line_kws: Kwargs specific for line plot
        fill_kws: Kwargs specific for fill between
        kwargs:  Shared kwargs
            Requires: x and y1, ym, y2
    """
    line_kws = line_kws.copy() or {}
    fill_kws = fill_kws.copy() or {}

    y1 = kwargs.pop("y1")
    ym = kwargs.pop("ym")
    y2 = kwargs.pop("y2")
    x = kwargs.pop("x")

    ax = kwargs.pop("ax", get_current_actor())

    line_kws.update(kwargs)
    fill_kws.update(kwargs)

    ax.plot(x, ym, **line_kws)
    ax.fill_between(x, y1, y2, **fill_kws)

    return ax
Beispiel #3
0
def plot_posterior_fit(**kwargs):
    """Fits normal distribution to ensemble and plots normal dist as well as hist
    """
    ax = get_current_actor()
    x = kwargs["data"].x.values
    distplot(a=x, kde=False, ax=ax, hist_kws={"density": True})
    plot_gv_dist(fit_norm_dist_to_ens(x, thresh=kwargs.get("thresh", None)),
                 ax=ax,
                 color="black")
Beispiel #4
0
def plot_gv_dist(gvar: NormalDistVar, **kwargs):
    """Plots pdf of gvar
    """
    ax = kwargs.pop("ax", get_current_actor())

    normal = gv_to_dist(gvar)
    x = linspace(normal.ppf(0.001), normal.ppf(0.999), 100)
    y_fit = normal.pdf(x)
    ax.plot(x, y_fit, **kwargs)

    return ax
Beispiel #5
0
def plot_prior_fit(**kwargs):
    """Parses distribution from meta parameters and plots exact distribution and
    normal fit
    """
    data = kwargs["data"].iloc[0].to_dict()
    dist = parse_dist(data)

    ax = get_current_actor()

    x = linspace(dist.ppf(0.001), dist.ppf(0.999), 100)
    y = dist.pdf(x)
    ax.fill_between(x, y, alpha=0.5)

    plot_gv_dist(fit_norm_dist_to_dist(dist), color="black")