Python script "y.py"

Not mandatory, but useful: A Python script which allows to plot two curves. Assume our C-program produces output in the form of three columns, representing two curves (which we want to compare). The first column represents the common x-values of the two curves.

First create (just once) a file called "y.py", with the following content:

#!/usr/bin/python
import matplotlib.pyplot as plt;
from pylab import genfromtxt;
xx = genfromtxt("out");
plt.plot(xx[:,0], xx[:,1], label = "data 1");
plt.plot(xx[:,0], xx[:,2], "bs" ,label = "data 2");
plt.xlabel('x variable')
plt.ylabel('y variable')
plt.legend();
plt.show();


Run the C-program, which creates the three columns, but do not print on the screen, but into a file called "out", via

a.out > out

Execute the python script via

python y.py

Which will plot the two curves.