cb = plt.colorbar(sc)
cb.set_label('Effective number of samples')

plt.xlim(-25., 25.)
plt.ylim(-25., 25.)
plt.tight_layout()
#plt.show()
plt.savefig("effectiveNSamples.pdf")

# ## 2. Plot cross section over parameter space

# This is not strictly necessary, but we can also plot the cross section as a function of parameter space:

# In[7]:

thetas_benchmarks, xsecs_benchmarks, xsec_errors_benchmarks = sampler.cross_sections(
    theta=sampling.benchmarks(list(sampler.benchmarks.keys())))

thetas_morphing, xsecs_morphing, xsec_errors_morphing = sampler.cross_sections(
    theta=sampling.random_morphing_points(1000, [('gaussian', 0.,
                                                  4.), ('gaussian', 0., 4.)]))

# In[8]:

cmin, cmax = 0., 2.5 * np.mean(xsecs_morphing)

fig = plt.figure(figsize=(5, 4))

sc = plt.scatter(thetas_morphing[:, 0],
                 thetas_morphing[:, 1],
                 c=xsecs_morphing,
                 s=40.,
        mode="rate",
        include_xsec=True,
        resolutions=resolutions,
        luminosity=uselumi)

    np.save('/home/rates/grid.npy', theta_grid)
    np.save('/home/rates/rate.npy',
            [p_values_expected_xsec, best_fit_expected_xsec])

    sa_rates = SampleAugmenter(h5_file, include_nuisance_parameters=False)
    xs_grid = []
    neff_grid = []
    n_test = 10000

    for theta_element in theta_grid:
        _, xs, _ = sa_rates.cross_sections(
            theta=sampling.morphing_point(theta_element))
        _, _, neff = sa_rates.sample_train_plain(
            theta=sampling.morphing_point(theta_element), n_samples=n_test)
        xs_grid.append(xs)
        neff_grid.append(neff / float(n_test))
    neff_grid = np.array(neff_grid)
    xsgrid = np.array(xs_grid)

    np.save('/home/rates/neff_grid.npy', neff_grid)
    np.save('/home/rates/xs_grid.npy', xs_grid)

    for bool_xsec in xsec:
        # histogram + save
        _, p_values_expected_histo, best_fit_expected_histo = limits.expected_limits(
            theta_true=theta_true,
            theta_ranges=theta_ranges,