Esempio n. 1
0
def plot_model_fit(model_df, predictions, x_col, y_col, condition_x,
                   condition_y):
    """Scatterplot of y data vs x data with the natural cubic spline visualized and the line y=x for reference

    Parameters
    ----------
    model_df: DataFrame
        Dataframe with columns x_col and y_col for modeling
    predictions: array_like
        Array of predictions from the fit model
    x_col: str
        X column in data to model
    y_col: str
        Y column in data to model
    condition_x: str
        Name of the plot's x axis
    condition_y: str
        Name of the plot's y axis

    Returns
    -------
    matplotlib.axes.Axes
    matplotlib.figure.Figure

    """
    fig, ax = plt.subplots(figsize=(4, 4))
    gpplot.point_densityplot(data=model_df, x=x_col, y=y_col, alpha=0.3)
    ordered_x, ordered_predictions = zip(
        *sorted(zip(model_df[x_col], predictions)))
    ab_ends = [ax.get_xlim()[0], ax.get_xlim()[1]]
    plt.plot(ab_ends, ab_ends, label='y=x', linestyle='--', color='grey')
    plt.plot(ordered_x, ordered_predictions, color='black', label='fit line')
    plt.xlabel(condition_x)
    plt.ylabel(condition_y)
    plt.legend()
    return fig, ax
Esempio n. 2
0
def test_add_correlation(scatter_data):
    ax = gpplot.point_densityplot(scatter_data, 'x', 'y')
    ax = gpplot.add_correlation(scatter_data, 'x', 'y', size=12, color='blue')
Esempio n. 3
0
def test_add_xyline(scatter_data):
    ax = gpplot.point_densityplot(scatter_data, 'x', 'y')
    ax = gpplot.add_xy_line()
Esempio n. 4
0
def test_point_density_plot(scatter_data):
    ax = gpplot.point_densityplot(scatter_data, 'x', 'y')