示例#1
0
def plotting(data1, data2, config_file, smash_code_version, output_folder):
    quantities = data1.quantities.union(data2.quantities)
    pdglist = data1.pdglist.union(data2.pdglist)
    pdglist_abs = np.unique(np.abs(np.array(list(pdglist))))
    colliding_systems = data1.colliding_systems.union(data2.colliding_systems)
    colliding_systems_list = list(colliding_systems)
    energies = sorted(list(data1.energies.union(data2.energies)))

    for quantity in quantities:
        if ('spectra' in quantity): continue
        collected_results_pp = [[], [], []]
        collected_results_AuAuPbPb = [[], [], []]
        for pdg_abs in pdglist_abs:
            # Sigma0 is added to Lambda plots
            if (pdg_abs == 3212): continue
            # We do not want the Deuteron plots to be displayed, because SMASH
            # needs to be modified for useful results (cross section cut off)
            if (pdg_abs == 1000010020): continue
            pdg_one_sort = []
            if (pdg_abs in pdglist): pdg_one_sort.append(pdg_abs)
            if (-pdg_abs in pdglist): pdg_one_sort.append(-pdg_abs)
            for pdg in pdg_one_sort:
                for colliding_system in colliding_systems:
                    if (pdg == pdg_abs):
                        plot_format = '-'
                        plot_label = colliding_system
                        exp_fmt = 'o'
                    else:
                        plot_format = '--'
                        plot_label = ''
                        exp_fmt = 's'

                    if (colliding_system == 'pp'):
                        linewidth = 5
                        plot_color = 'midnightblue'
                    else:
                        linewidth = 5
                        plot_color = 'darkred'
                    if data1.is_in_dict([quantity, colliding_system, pdg]):
                        theory_vs_energy = data1.the_dict[quantity][
                            colliding_system][pdg]
                        x, y = zip(*sorted(theory_vs_energy.iteritems()))
                        plt.plot(x,
                                 y,
                                 plot_format,
                                 label=plot_label,
                                 color=plot_color,
                                 lw=linewidth)

                        # store results in list to later save it for future comparison
                        if (colliding_system == 'pp'):
                            collected_results_pp[0].append(pdg)
                            if (collected_results_pp[1] == []):
                                collected_results_pp[1].append(x)
                            collected_results_pp[2].append(y)
                        if (colliding_system == 'AuAu/PbPb'):
                            collected_results_AuAuPbPb[0].append(pdg)
                            if (collected_results_AuAuPbPb[1] == []):
                                collected_results_AuAuPbPb[1].append(x)
                            collected_results_AuAuPbPb[2].append(y)

                        if args.comp_prev_version:
                            import comp_to_prev_version as cpv
                            # read and plot results from previous version
                            filename_prev = quantity + '_' + colliding_system.replace(
                                '/', '')
                            prev_SMASH_version = cpv.plot_previous_results(
                                'energy_scan',
                                '',
                                filename_prev + '.txt',
                                plot_color=plot_color,
                                pdg=pdg,
                                plot_style=plot_format)

                    if data2.is_in_dict([quantity, colliding_system, pdg]):
                        exp_vs_energy = data2.the_dict[quantity][
                            colliding_system][pdg]
                        x_exp, y_exp = zip(*sorted(exp_vs_energy.iteritems()))
                        y_exp_values, y_exp_errors = zip(*y_exp)
                        plt.errorbar(x_exp, y_exp_values, yerr = y_exp_errors, fmt = exp_fmt,\
                                     color = plot_color, elinewidth = 2, markeredgewidth = 0)

            if args.comp_prev_version:
                #dummy, for combined legend entry of previous results.
                plt.plot(1,
                         0.0,
                         linestyle='-',
                         linewidth=10,
                         zorder=1,
                         alpha=0.2,
                         color='dimgrey',
                         label=prev_SMASH_version)

            plt.xlabel('$\sqrt{s_{NN}} [GeV]$')
            plt.xscale('log')

            if (quantity in ['total_multiplicity', 'midrapidity_yield']):
                if np.all(y == 0):
                    print 'No positive values encountered in ' + str(quantity) + ' for ' + str(pdg) +\
                          '. Cannot log-scale the y axis, scale will be linear.'
                else:
                    plt.yscale('log', nonposy='clip')
            hadron_name = sb.pdg_to_name(pdg_abs, config_file).decode("utf-8")
            antihadron_name = sb.pdg_to_name(-pdg_abs,
                                             config_file).decode("utf-8")
            plot_title = hadron_name
            if not pdg_abs in [111, 333]:  # antiparticle of itself
                plot_title += ' (' + antihadron_name + ' dashed, squares)'
            title_dict = {
                'total_multiplicity': ' $4\pi$ multiplicity',
                'midrapidity_yield': ' $dN/dy|_{y = 0}$',
                'meanmt0_midrapidity':
                ' $<m_{T}>|_{y = 0}$, $m_{T} = \sqrt{p_T^2 + m^2} - m$',
                'meanpt_midrapidity': ' $<p_{T}>|_{y = 0}$'
            }
            plt.title(plot_title)
            plt.ylabel(title_dict[quantity])
            plt.legend()
            plt.figtext(0.8, 0.94, " SMASH code:      %s\n SMASH analysis: %s" % \
                         (smash_code_version, sb.analysis_version_string()), \
                         color = "gray", fontsize = 10)
            plt.savefig(output_folder + '/' + quantity + str(pdg_abs) + '.pdf')
            plt.clf()

        # Save results plotted above for future comparison
        filename_AuAuPbPb = quantity + '_' + 'AuAuPbPb' + '.txt'
        filename_pp = quantity + '_' + 'pp' + '.txt'

        store_results(output_folder + '/' + filename_AuAuPbPb,
                      collected_results_AuAuPbPb, smash_code_version, quantity)
        store_results(output_folder + '/' + filename_pp, collected_results_pp,
                      smash_code_version, quantity)

    # Plotting spectra, only those, where some data is present
    for quantity in quantities:
        if (quantity
                not in ['yspectra', 'mtspectra', 'ptspectra', 'v2spectra']):
            continue
        if (quantity == 'v2spectra' and not args.with_v2): continue
        for pdg in pdglist:
            if (abs(pdg) == 3212): continue
            if (abs(pdg) == 1000010020): continue
            collected_results_pp = [[], [], []]
            collected_results_AuAuPbPb = [[], [], []]
            for colliding_system in colliding_systems:
                #if not data2.is_in_dict([quantity, colliding_system, pdg]): continue
                #if not data1.is_in_dict([quantity, colliding_system, pdg]): continue

                # colors list for plotting
                col = cycle(colours)
                # to scale curves in mT and pT spectra by powers of 10 -> readability
                scaling_counter = -1
                for element, energy in enumerate(energies):
                    collider = determine_collider(energy)
                    in_theory = data1.is_in_dict(
                        [quantity, colliding_system, pdg, energy])
                    in_experiment = data2.is_in_dict(
                        [quantity, colliding_system, pdg, energy])
                    #if (not in_experiment): continue
                    if (in_experiment and not in_theory):
                        print energy, colliding_system, pdg, in_theory, in_experiment, \
                              ': there is experimental data, but no SMASH calculation!'
                    if (in_theory):
                        plot_color = next(col)
                        bin_edges, y = data1.the_dict[quantity][
                            colliding_system][pdg][energy]
                        bin_edges = np.array(bin_edges)
                        bin_width = bin_edges[1:] - bin_edges[:-1]
                        x = 0.5 * (bin_edges[1:] + bin_edges[:-1])
                        y = np.array(y)
                        # dN/dy
                        if (quantity == 'yspectra'):
                            y /= bin_width
                            plt.plot(x,
                                     y,
                                     '-',
                                     lw=4,
                                     color=plot_color,
                                     label=str(energy))
                        # dN/dmT
                        pole_masses = {
                            111: 0.138,
                            211: 0.138,
                            321: 0.495,
                            2212: 0.938,
                            3122: 1.116,
                            3312: 1.321,
                            3334: 1.672,
                            1000010020: 1.8756,
                            3212: 1.189
                        }
                        m0 = pole_masses[abs(pdg)]
                        if (quantity == 'mtspectra'):
                            scaling_counter += 1
                            y /= ((x + m0) * bin_width) * (
                                2.0 * data1.midrapidity_cut
                            )  # factor 2 because [-y_cut; y_cut]
                            if np.all(
                                    y == 0
                            ):  # rescale y-axis to be linear if mtspectra of current energy are 0, but those
                                plt.yscale(
                                    'linear'
                                )  # of the previous energy were not, so that the scale was already set to log scale.
                            plt.plot(x,
                                     y * 10**scaling_counter,
                                     '-',
                                     lw=4,
                                     color=plot_color,
                                     label=str(energy) +
                                     r' $\times \ $10$^{\mathsf{' +
                                     str(scaling_counter) + r'}}$')
                        # dN/dpT
                        if (quantity == 'ptspectra'):
                            scaling_counter += 1
                            y /= (bin_width * x) * (
                                2.0 * data1.midrapidity_cut
                            )  # factor 2 because [-y_cut; y_cut]
                            if np.all(
                                    y == 0
                            ):  # rescale y-axis to be linear if ptspectra of current energy are 0, but those
                                plt.yscale(
                                    'linear'
                                )  # of the previous energy were not, so that the scale was already set to log scale.
                            plt.plot(x,
                                     y * 10**scaling_counter,
                                     '-',
                                     lw=4,
                                     color=plot_color,
                                     label=str(energy) +
                                     r' $\times \ $10$^{\mathsf{' +
                                     str(scaling_counter) + r'}}$')
                        # v2
                        if (quantity == 'v2spectra'):
                            y /= (bin_width) * (
                                2.0 * data1.midrapidity_cut
                            )  # factor 2 because [-y_cut; y_cut]
                            plt.plot(x,
                                     y,
                                     '-',
                                     lw=4,
                                     color=plot_color,
                                     label=str(energy))

                        # store results in list to later save for future comparison
                        if (colliding_system == 'pp'):
                            collected_results_pp[0].append(energy)
                            if (collected_results_pp[1] == []):
                                collected_results_pp[1].append(x)
                            collected_results_pp[2].append(y)
                        if (colliding_system == 'AuAu/PbPb'):
                            collected_results_AuAuPbPb[0].append(energy)
                            if (collected_results_AuAuPbPb[1] == []):
                                collected_results_AuAuPbPb[1].append(x)
                            collected_results_AuAuPbPb[2].append(y)

                        # read and plot results from previous version
                        if args.comp_prev_version and quantity != 'v2spectra':
                            #v2 is not regularly run, old results are neither produced nor stored
                            filename_prev = quantity + '_' + colliding_system.replace(
                                '/', '') + '_' + str(pdg)
                            prev_SMASH_version = cpv.plot_previous_results(
                                'energy_scan',
                                '',
                                filename_prev + '.txt',
                                energy=energy,
                                plot_color=plot_color,
                                scaling_counter=scaling_counter)

                    if (in_experiment):
                        x, y, y_err = data2.the_dict[quantity][
                            colliding_system][pdg][energy]
                        if (quantity == 'mtspectra'):
                            plt.errorbar(x,
                                         y * 10**scaling_counter,
                                         yerr=y_err,
                                         fmt='o',
                                         color=plot_color)
                        elif (quantity == 'ptspectra'):
                            plt.errorbar(x,
                                         y * 10**scaling_counter,
                                         yerr=y_err,
                                         fmt='o',
                                         color=plot_color)
                        elif (quantity == 'v2spectra'):
                            plt.errorbar(x,
                                         y,
                                         yerr=y_err,
                                         fmt='o',
                                         color=plot_color)
                        else:  # yspectra
                            plt.errorbar(x,
                                         y,
                                         yerr=y_err,
                                         fmt='o',
                                         color=plot_color)
                    title_dict = {
                        'yspectra': '$dN/dy$',
                        'mtspectra': '$1/m_{T} \ d^2N/dm_{T} dy$ [GeV$^{-2}$]',
                        'ptspectra': '$1/p_{T} \ d^2N/dp_{T} dy$ [GeV$^{-2}$]',
                        'v2spectra': '$v_2$',
                    }

                    plot_title = sb.pdg_to_name(pdg,
                                                config_file).decode("utf-8")
                    plot_title += ' in ' + colliding_system + ' collisions'
                    plt.title(plot_title)
                    plt.figtext(0.15, 0.94, " SMASH code:      %s\n SMASH analysis: %s" % \
                        (smash_code_version, sb.analysis_version_string()), \
                        color = "gray", fontsize = 10)
                    if (quantity == 'mtspectra' or quantity == 'ptspectra'):
                        if np.all(y == 0):
                            print 'No positive values encountered in ' + str(quantity) + ' for ' + str(pdg) +\
                                  '. Cannot log-scale the y axis, scale will be linear.'
                        else:
                            plt.yscale('log', nonposy='clip')
                        if (quantity == 'mtspectra'):
                            plt.xlabel('$m_{T} - m_{0}$ [GeV]')
                        else:
                            plt.xlabel('$p_{T}$ [GeV]')
                    elif (quantity == 'yspectra'):
                        plt.xlabel('$y$')
                    else:
                        plt.xlabel('$p_{T}$ [GeV]')

                    plt.ylabel(title_dict[quantity])
                    if (determine_collider(energy) != determine_collider(
                            energies[(element + 1) % len(energies)])):
                        if args.comp_prev_version:
                            #dummy for legend entry of combined previous results.
                            plt.plot(1,
                                     0.0,
                                     linestyle='-',
                                     linewidth=10,
                                     zorder=1,
                                     color='dimgrey',
                                     label=prev_SMASH_version,
                                     alpha=0.2)
                        plt.legend(loc='upper right',
                                   title='$\sqrt{s} \ $ [GeV] =',
                                   ncol=1,
                                   fontsize=26)
                        plt.savefig(output_folder + '/' + quantity + '_' +
                                    colliding_system.replace('/', '') + '_' +
                                    str(determine_collider(energy)) + '_' +
                                    str(pdg) + '.pdf')
                        plt.clf()
                        plt.close()
                        scaling_counter = -1  #re-initialize as generating a new plot

            # Save results plotted above for future comparison
            filename_AuAuPbPb = quantity + '_AuAuPbPb_' + str(pdg) + '.txt'
            filename_pp = quantity + '_pp_' + str(pdg) + '.txt'

            store_results(output_folder + '/' + filename_AuAuPbPb,
                          collected_results_AuAuPbPb, smash_code_version,
                          quantity)
            store_results(output_folder + '/' + filename_pp,
                          collected_results_pp, smash_code_version, quantity)
with open(DataOutfile, 'r') as f:
    _, _, versions = \
    f.readline(), f.readline(), f.readline()
smash_version = versions.split()[1]
smash_analysis_version = versions.split()[2]

TimeSteps, dens_arr = np.loadtxt(DataOutfile, unpack=True, skiprows=5)

plt.plot(TimeSteps, dens_arr, label=smash_version, color='darkred')

# old version ?
if comp_prev_version:
    import comp_to_prev_version as cpv
    processes = []
    cpv.plot_previous_results('densities',
                              DataOutfile.split('/')[-2],
                              '/' + DataOutfile.split('/')[-1])

plt.title(r'Density central cell', loc='left', fontsize=30)
plt.figtext(0.8, 0.95, "SMASH analysis: %s" % \
             (sb.analysis_version_string()), \
             color = "gray", fontsize = 10)
plt.xlabel(r't [fm]')
plt.ylabel(r'$\rho_\mathsf{B}/\rho_0$')
plt.xlim(0, 40)
plt.ylim(0, 5)
plt.tight_layout()
plt.legend()
plt.savefig(PlotName, bbox_inches="tight")
plt.close()
示例#3
0
### (4a) Plot experimental data
if args.exp_data != '':
    import comp_to_exp_data as ced
    ced.plot_angular_dist_data(args.exp_data, setup, pdg=[pdg1, pdg2])

### (4b) plot data from previous SMASH versions
if args.comp_prev_version:
    import comp_to_prev_version as cpv
    processes = [
        'total', 'N+N', 'N+N*', 'N+\xce\x94', 'N*+\xce\x94', 'N+\xce\x94*',
        '\xce\x94+\xce\x94', '\xce\x94+\xce\x94*'
    ]
    cpv.plot_previous_results('angular_distributions',
                              setup,
                              '/t.dat',
                              color_list=colour_coding,
                              process_list=processes)

### (5) set up axes, labels, etc
plt.title(
    particle1.decode('utf8') + "+" + particle2.decode('utf8') +
    " @ $\sqrt{s}=" + str(round(np.sqrt(s), 2)) + "$ GeV")
plt.xlabel("-t [$GeV^2$]")
plt.ylabel("$d\sigma/dt$ [$mb/GeV^2$]")
plt.yscale('log')
plt.legend(title=smash_version, loc="best", fontsize=20, ncol=2)
plt.figtext(0.8, 0.925, "SMASH analysis: %s" % \
             (sb.analysis_version_string()), \
             color = "gray", fontsize = 10)
plt.tight_layout()
    for i in range(0, len(descr_both)):
        f.write(
            unicode(descr_both[i]) + '\t' +
            str((contents[1::3].sum(axis=1) * react_norm)[i]) + '\t' +
            str((contents[2::3].sum(axis=1) * react_norm)[i]) + '\n')
    f.write('# ' + smash_code_version)

ymax = max(max(contents[1::3].sum(axis=1) * react_norm),
           max(contents[2::3].sum(axis=1) * react_norm))

# plot reference data from previous SMASH version
if args.comp_prev_version:
    import comp_to_prev_version as cpv
    cpv.plot_previous_results('detailed_balance',
                              setup,
                              '/Nreact_by_Nisopingroup.txt',
                              process_list=descr_both,
                              ymax=ymax)

plt.plot(1,
         ymax * 4.0,
         linestyle='none',
         markersize=20,
         color='black',
         marker=">",
         label=str(smash_code_version))
plt.axhline(y=1, linestyle='-', color='grey', zorder=0, lw=1)
plt.xticks(range(react_num), descr_both, fontsize=15, rotation=35)
plt.yticks([0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4], fontsize=35)
plt.ylim(0.0, ymax * 1.5)
plt.xlim(-0.5, react_num - 0.5)
示例#5
0
    title = reac[1] + THIN_SPACE + reac[2]
    if final_state_names and len(final_state_names) == 1:
        title += '→' + final_state_names[0]
    title = title.replace('+', THIN_SPACE)
    ax.set_title(title)
    ax.set_xlabel(colnames[0])
    ax.set_ylabel("$\sigma$ [mb]")

    smash_style.set()

    # (4a) plot data from previous SMASH version
    # after applying the SMASH style! Otherwise this curve would be reformatted
    # plot only total_xs from prev. version if current one is plotted as well
    if args.comp_prev_version:
        import comp_to_prev_version as cpv
        cpv.plot_previous_results('cross_sections', str(args.system),
                                  '/sqrts_totalXSec.txt')

    # Shrink current axis
    box = ax.get_position()
    ax.set_position([box.x0, box.y0, box.width * 0.5, box.height])
    plt.legend(title=version,
               loc='center left',
               bbox_to_anchor=(1.04, 0.5),
               borderaxespad=0.)
    plt.figtext(0.8, 0.92, "SMASH analysis: %s" % \
                 (sb.analysis_version_string()), \
                 color = "gray", fontsize = 10)
    #if nlabels < 7:
    #    ncol = 1
    #elif nlabels < 13:
    #    ncol = 2
示例#6
0
def plot(name, bin_factor, ch_list, style_dict, datafile="", cut_legend=""):

    n_ch = len(ch_list)

    # import hist_data
    with open("hist_" + name + ".txt") as df_smash:
        data = np.loadtxt(df_smash, delimiter=' ', unpack=True)

    bin_centers = data[0, :]
    hist = data[1:n_ch + 1, :]

    # make dN/dx plot
    bin_width = bin_centers[1] - bin_centers[0]
    hist_dx = hist[:] / bin_width

    # renormalize for data comparison (currently only mass spectra compared with data)
    if datafile != "":
        # do cross section plot for pp, data in mub
        if args.system == "pp" or args.system == "pNb":
            hist_dx = hist_dx * \
                cross_sections_dict[args.system + args.energy] * 1000
        # spectra for CC is normalized with averaged number of pions
        if args.system == "CC" or args.system == "ArKCl":
            hist_dx = hist_dx / normalization_AA()

    # rebin
    bin_centers_new, hist_new = rebin(bin_centers, hist_dx, n_ch, bin_factor)

    # plotting
    plt.plot(bin_centers_new,
             sum(hist_new),
             label="all",
             color='k',
             linewidth=3)
    for i in range(len(ch_list)):
        plt.plot(bin_centers_new,
                 hist_new[i],
                 style_dict["l_style"][i],
                 label=ch_list[i],
                 linewidth=2)

    # plot data
    if datafile != "":
        if 'mass' in name:
            data_path = os.path.join(
                args.data_dir + 'm_inv_spectrum_dileptons/' + args.system,
                datafile)
        elif 'pt' in name:
            data_path = os.path.join(
                args.data_dir + 'pT_spectrum/' + args.system + '/', datafile)
        elif 'y' in name:
            data_path = os.path.join(
                args.data_dir + 'y_spectrum/' + args.system + '/', datafile)
        else:
            print 'No experimental data found.'

        with open(data_path) as df:
            data = np.loadtxt(df, unpack=True)

        x_data = data[0, :]
        y_data = data[1, :]
        y_data_err = data[2, :]

        plt.errorbar(x_data,
                     y_data,
                     yerr=y_data_err,
                     fmt='ro',
                     ecolor='k',
                     label="HADES",
                     zorder=3)

    # write and read old results, only for total dN/dm spectra
    if name == "mass":
        # store dN/dm spectra for future comparison to previous version
        store_results("dN_dm_tot.txt", bin_centers_new, sum(hist_new),
                      version())

        if args.comp_prev_version:
            import comp_to_prev_version as cpv
            # plot reference data from previous SMASH version
            setup = str(args.system) + "_" + str(
                args.energy) + "_" + "filtered"
            cpv.plot_previous_results('dileptons', setup, '/dN_dm_tot.txt')

    # plot style
    leg = plt.legend(bbox_to_anchor=(0., 1.02, 1., .102),
                     loc=3,
                     ncol=2,
                     mode="expand",
                     borderaxespad=0,
                     fancybox=True,
                     title=args.system + "@" + args.energy + " GeV " +
                     cut_legend)
    #plt.annotate(version(), xy=(0.02, 0.03), xycoords='axes fraction', bbox=dict(boxstyle="round", fc="w"), fontsize=12)
    plt.annotate('SMASH version: ' + version() + '\n' +
                 'Analysis suite version: ' + sb.analysis_version_string(),
                 xy=(0.4, 0.92),
                 xycoords='axes fraction',
                 bbox=dict(boxstyle="round", fc="w"),
                 fontsize=8)
    plt.xlim(style_dict["x_min"], style_dict["x_max"])
    plt.ylim(style_dict["y_min"], style_dict["y_max"])
    plt.xlabel(style_dict["xlab"])
    plt.ylabel(style_dict["ylab"])
    plt.yscale('log')
    plt.savefig("plot_" + name + ".pdf",
                bbox_extra_artists=(leg, ),
                bbox_inches='tight')
    plt.cla()
示例#7
0
y /= N
plt.errorbar(x,
             y,
             yerr=yerr,
             label=version,
             color="darkred",
             linestyle='-',
             zorder=3)

# store results
save_table(OrderedDict([('x', x), ('y', y), ('yerr', yerr)]),
           'multiplicity.txt', version)

if args.comp_prev_version:  # Compare to previous version
    import comp_to_prev_version as cpv
    cpv.plot_previous_results('FOPI_pions', 'multiplicity', '.txt')

smash_style.set(line_styles=False, update_legends=True)

plt.xlabel("$E_{kin}$ [AGeV]")
plt.xlim(0.3, 1.6)
plt.yscale('log')
plt.ylim(2, 100)
plt.ylabel(r"$M(\pi)=3/2\,(N_{\pi^+}+N_{\pi^-})$")
plt.legend(loc="lower right")

### (3) plot ratio

plt.subplot(312)
if args.FOPI_ratio != '':
    if 'ced' not in sys.modules:
示例#8
0
def plot_data(input_txt_file, plot_position, plot_color):

    plt.subplot(gs[plot_position,0])

    coll_criterion_name = os.path.basename(input_txt_file)[9:-4]
    plt.annotate(coll_criterion_name + " criterion",
                xy=(0.03, 0.075), xycoords='axes fraction',weight='heavy' , color=plot_color, fontsize =40)

    # Get data from file
    data = np.genfromtxt(input_txt_file, names=('Ncoll', 'Nevents',
                   't_run', 'V', 'sigma', 'N', 'Ntest', 'T', 'dt'))

    with open(input_txt_file, 'r') as f:
        smash_version = f.readlines()[-1].strip('# \n')

    # Sort by x axis variable
    data = data[data[xvar].argsort()]

    x = data[xvar]
    y = data['Ncoll']

    # Make a text label about the properties of the used box
    s=[]
    s.append('Elastic Box$:$')
    if (xvar != 'V'):     s.append("$V$ = %.1f fm$^3$"      % data['V'][0])
    if (xvar != 'sigma'): s.append("$\sigma$ = %.1f fm$^2$" % data['sigma'][0])
    if (xvar != 'N'):     s.append("$N$ = %i"               % data['N'][0])
    if (xvar != 'Ntest'): s.append("$N_{test}$ = %i"        % data['Ntest'][0])
    if (xvar != 'T'):     s.append("$T$ = %.3f GeV"         % data['T'][0])
    if (xvar != 'dt'):    s.append("$dt$ = %s fm/c"         % data['dt'][0])
    s.append("$t_{tot}$ = %.1f fm/c"    % data['t_run'][0])
    s.append("$N_{ev}$ = %i"            % data['Nevents'][0])
    box_label = '\n'.join(s)

    if plot_position == 0:  # only print title and input box once
        plt.annotate(box_label, xy=(1.02, 0.97), ha="left", va="top", xycoords='axes fraction', fontsize=30)
        plt.title('only $\pi^0$, only elastic collisions', fontsize=30, y=1.02)
    if plot_position == 2:  # print xlabel only once
        plt.annotate(y_label_defintion, xy=(0.72, 0.175), xycoords='axes fraction', fontsize =30)


    # Number of collisions is expected to be equal to this norm (for <v> = c)
    norm = data['Nevents'] * data['t_run'] * (data['sigma'] * 0.5 * data['N'] * data['N'] * data['Ntest'] / data['V'])

    # Average relative velocity factor, arXiv:1311.4494, matters only at m/T < 0.7
    a = 0.135/data['T']  # m_pi0/T
    v_rel = 4./a * sp.kn(3, 2.0*a) / np.power(sp.kn(2, a), 2)
    norm *= v_rel

    y = y / norm
    y_error = np.sqrt(data['Ncoll']) / norm
    plt.errorbar(x, y, yerr=y_error, fmt='o', capsize=10,
                label=smash_version, markersize = 15,
                zorder = 2, markeredgecolor= plot_color, color=plot_color)

    if args.comp_prev_version:
       import comp_to_prev_version as cpv
       # plot reference data from previous SMASH version
       cpv.plot_previous_results('elastic_box', args.setup, '-' + coll_criterion_name + '.txt')

    plt.xlim(0.0, 1.05 * x.max())
    plt.ylim(ymin=0.4, ymax=max(1.75, 1.1 * y.max()))
    if (xvar == 'dt'):
        plt.xscale('log')
        plt.xlim(1.e-4, 2.0 * x.max())
        plt.gca().tick_params(pad=10)

    # store plotted data
    save_table(
        OrderedDict([('x', x), ('y', y), ("y_error", y_error)]),
        '{}.txt'.format(args.setup + "-" + coll_criterion_name),
        smash_version,
    )

    plt.legend(loc = 'upper right', fontsize = 30)
    plt.axhline(1, linewidth=3, linestyle='--', color='black', zorder = 0)
    if plot_position == 1:
        plt.ylabel(y_label, fontsize=50)
    if plot_position == 2:
        plt.xlabel(x_labels[xvar])