import numpy as np
import matplotlib.pyplot as plt

pathToResults = '/home/ADF/middlehr/Documents/PTA/EPTAInterp/results/agn_model/single/'
run='singleChain2'
name = '_s2'


chains = np.genfromtxt(pathToResults+run+'/posterior.dat', names=True)

nparameters = 5
fig, axes = plt.subplots(nparameters, figsize=(10, 10), sharex=True)

labels = (['logn', 'beta', 'gamma', 'alpha', 'delta'])

print(labels)
#labels = ["m", "b", "log(f)"]
for i in range(nparameters):
    ax = axes[i]
    ax.plot(chains[labels[i]], "k", alpha=0.7)
    ax.set_xlim(0, len(chains))
    ax.set_ylabel(labels[i],rotation=0)
    ax.yaxis.set_label_coords(-0.1, 0.5)



axes[-1].set_xlabel("step number");


plt.savefig('{0}{1}/chains{2}.png'.format(pathToResults,run,name))
plt.show()
