#! /usr/bin/env python

#
# two_springs_plot.py
#
"""
Plot the solution that was generated by two_springs_solver.py.
"""
import sys
import pylab as pl
from matplotlib.font_manager import FontProperties

# Set input file using user parameter
if len(sys.argv) > 1:
	f = open(sys.argv[1],'r')
else:
	f = sys.stdin

data = pl.loadtxt(f)

# TODO: Understand this sentence! Set on a column basis?
t  = data[:,0]
x1 = data[:,1]
y1 = data[:,2]
x2 = data[:,3]
y2 = data[:,4]

f1 = pl.figure(1,figsize=(6,4)).subplots_adjust(bottom=0.11)

pl.xlabel('t')
pl.grid(True)
pl.hold(True)
lw = 1

pl.plot(t,x1,'b',linewidth=lw)
pl.plot(t,x2,'g',linewidth=lw)

pl.legend((r'$x_1$',r'$x_2$'),prop=FontProperties(size=16))
pl.title('Mass Displacements for the Coupled Spring-Mass System')
savefig('two_springs.png',dpi=72)
pl.show()
