Ejemplo n.º 1
0
def test_mean_diff_plot():

    # Seed the random number generator.
    # This ensures that the results below are reproducible.
    np.random.seed(11111)
    m1 = np.random.random(20)
    m2 = np.random.random(20)

    fig = plt.figure()
    ax = fig.add_subplot(111)

    # basic test.
    fig = mean_diff_plot(m1, m2, ax=ax)
    plt.close(fig)

    # Test with pandas Series.
    p1 = pd.Series(m1)
    p2 = pd.Series(m2)
    fig = mean_diff_plot(p1, p2)
    plt.close(fig)

    # Test plotting on assigned axis.
    fig, ax = plt.subplots(2)
    mean_diff_plot(m1, m2, ax=ax[0])
    plt.close(fig)

    # Test the setting of confidence intervals.
    fig = mean_diff_plot(m1, m2, sd_limit=0)
    plt.close(fig)

    # Test asethetic controls.
    fig = mean_diff_plot(m1, m2, scatter_kwds={'color': 'green', 's': 10})
    plt.close(fig)

    fig = mean_diff_plot(m1, m2, mean_line_kwds={'color': 'green', 'lw': 5})
    plt.close(fig)

    fig = mean_diff_plot(m1,
                         m2,
                         limit_lines_kwds={
                             'color': 'green',
                             'lw': 5,
                             'ls': 'dotted'
                         })
    plt.close(fig)
Ejemplo n.º 2
0
def test_mean_diff_plot():

    # Seed the random number generator.
    # This ensures that the results below are reproducible.
    np.random.seed(11111)
    m1 = np.random.random(20)
    m2 = np.random.random(20)

    fig = plt.figure()
    ax = fig.add_subplot(111)

    # basic test.
    fig = mean_diff_plot(m1, m2, ax=ax)
    plt.close(fig)

    # Test with pandas Series.
    p1 = pd.Series(m1)
    p2 = pd.Series(m2)
    fig = mean_diff_plot(p1, p2)
    plt.close(fig)

    # Test plotting on assigned axis.
    fig, ax = plt.subplots(2)
    mean_diff_plot(m1, m2, ax = ax[0])
    plt.close(fig)

    # Test the setting of confidence intervals.
    fig = mean_diff_plot(m1, m2, sd_limit = 0)
    plt.close(fig)

    # Test asethetic controls.
    fig = mean_diff_plot(m1, m2, scatter_kwds={'color':'green', 's':10})
    plt.close(fig)

    fig = mean_diff_plot(m1, m2, mean_line_kwds={'color':'green', 'lw':5})
    plt.close(fig)

    fig = mean_diff_plot(m1, m2, limit_lines_kwds={'color':'green',
                                                'lw':5,
                                                'ls':'dotted'})
    plt.close(fig)
Ejemplo n.º 3
0
if __name__ == '__main__':
    data_dir = Path('../data/simulated') / 'actual_plots'

    data = load_data(data_dir, 'aggregation_effects_S_*.csv', index_col=0)
    data['level'] = data['level'].map(level_mapper)

    data = data[data['order'].isin(
        'blocks snake_20 snake_40 snake_60 snake_80 snake'.split())]
    data = data[data['function'].isin('Martin_et_al_2000'.split())]
    data = data[data['level'].isin([
        v for k, v in level_mapper.items()
        if k in 'squares squares-ghetto ghetto-squares ghetto'.split()
    ])]
    data = data[data['bandwidth'] == 500]
    data = data[data['cell'] == 25]

    ols_model = smf.ols('S_by_plot ~ S_by_page', data=data).fit()
    print(ols_model.summary())
    # data.plot(kind='scatter', x='S_by_page', y='S_by_plot', c='level')

    data.plot(
        x='S_by_page',
        y='S_by_plot',
        c='level',
        kind='scatter',
        cmap=cm.get_cmap('viridis', len(level_mapper)),
    )
    mean_diff_plot(data['S_by_plot'], data['S_by_page'], sd_limit=3)
    plt.show()
Ejemplo n.º 4
0
ai_t1 = np.array(ai_t1)
jh_t1 = np.array(jh_t1)
hx_t1 = np.array(hx_t1)

fig, axes = plt.subplots(1, 3, sharey='row', figsize=(15, 6))
for i, (ax, title) in enumerate(
        zip(axes, ('\nAI versus E1', '\nAI versus E2', '\nE1 versus E2'))):
    ax.set_title(title, fontsize=16)
    if i > 0:
        ax.axes.get_yaxis().set_visible(False)

    ax.xaxis.set_ticks(np.arange(0, 2000, 400))
    ax.yaxis.set_ticks(np.arange(-800, 1800, 400))

mean_diff_plot(ai_t1, jh_t1, ax=axes[0], scatter_kwds={'alpha': 0.25})
mean_diff_plot(ai_t1, hx_t1, ax=axes[1], scatter_kwds={'alpha': 0.25})
mean_diff_plot(jh_t1, hx_t1, ax=axes[2], scatter_kwds={'alpha': 0.25})

for ax in axes:
    ax.axvline(x=850, linestyle='--')

plt.setp(axes, xlim=(0, 1800))
plt.setp(axes, ylim=(-900, 900))
plt.subplots_adjust(wspace=0.1, hspace=0, left=0.075)
fig.suptitle(
    'T1 (ms) - Bland-Altman plot comparing AI & expert measurements\n',
    fontsize=20)
fig.show()

######