#!/usr/bin/env python import numpy as np import matplotlib.pyplot as plt import matplotlib.style as style style.use('classic') x00 = np.genfromtxt('coord.dat', delimiter=',') dx = x00[1] - x00[0] x12 = x00 - 0.5 * dx x12 = np.append(x12, x12[len(x12)-1] + dx) q00 = np.genfromtxt('q00.dat', delimiter=',') q12 = np.genfromtxt('q12.dat', delimiter=',') qne = np.genfromtxt('qne.dat', delimiter=',') fig, (ax1, ax2, ax3, ax4) = plt.subplots (4,1,sharex=True) ax1.set_title('pressure') ax1.plot (x00, q00[:,0], 'ko-', fillstyle='none', label='init') #ax1.plot (x12, q12[:,0], 'ro-', fillstyle='none', label='t+1/2') ax1.plot (x00, qne[:,0], 'g^-', fillstyle='none', label='updated') ax2.set_title('velocity') ax2.plot (x00, q00[:,1], 'ko-', fillstyle='none', label='init') #ax2.plot (x12, q12[:,1], 'ro-', fillstyle='none', label='t+1/2') ax2.plot (x00, qne[:,1], 'g^-', fillstyle='none', label='updated') ax3.set_title('density') ax3.plot (x00, q00[:,2], 'ko-', fillstyle='none', label='init') #ax3.plot (x12, q12[:,2], 'ro-', fillstyle='none', label='t+1/2') ax3.plot (x00, qne[:,2], 'g^-', fillstyle='none', label='updated') ax4.set_title('bulk modulus') ax4.plot (x00, q00[:,3], 'ko-', fillstyle='none', label='init') #ax4.plot (x12, q12[:,3], 'ro-', fillstyle='none', label='t+1/2') ax4.plot (x00, qne[:,3], 'g^-', fillstyle='none', label='updated') ax1.legend() #ax2.legend() #ax3.legend() #ax4.legend() ax4.set_xlabel('x (m)') plt.tight_layout() plt.savefig ('res104.png', dpi=200, format='png')