Plot_me.py
Go to the documentation of this file.
1 # Author: M. Reichert
2 import matplotlib.pyplot as plt
3 import numpy as np
4 
5 # Plot the nuclei: n p d t he3 he4 li6 li7 be7
6 # The mass numbers are:
7 A = np.array([1,1,2,3,3,4,6,7,7])
8 names = ['n','p','d','t',r'$^3$He',r'$^4$He',r'$^6$Li',r'$^7$Li',r'$^7$Be']
9 
10 # Load the data
11 data = np.loadtxt("tracked_nuclei.dat",unpack=True)
12 # Time [s]
13 time = data[0]
14 # Abundance
15 Y = data[1:].T
16 # Mass fraction
17 X = Y * A
18 
19 # Set up the plot
20 fig = plt.figure()
21 ax = fig.gca()
22 colors = ['g','b','c','k','y','m','r','navy','teal']
23 
24 # Plot the mass fraction of every nucleus
25 for i in range(len(X.T)):
26  ax.plot(time,X.T[i],label=names[i],color=colors[i])
27 
28 # Set the style of the plot
29 ax.set_xlabel('Time [s]')
30 ax.set_ylabel('Mass fraction')
31 ax.set_xscale('log')
32 ax.set_yscale('log')
33 ax.set_xlim(time[0],time[-1])
34 ax.set_ylim(1e-14,1.1)
35 plt.legend(loc="upper center",bbox_to_anchor=(0.5, 1.17),ncol = 5,fancybox=True)
36 
37 # Save the plot
38 fig.savefig("bbn.pdf",bbox_inches='tight')
39 
40 # Show the plot
41 plt.show()