import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

Directory = 'C:/Users/sasha/Documents/0Lunar 2021/sashankredo2/redo_20Ma_freq_rebinned_100bins.csv'
df = pd.read_csv(Directory)

axes = plt.gca()
axes.set_ylim([0,2.0])
# plt.scatter(df['Age']/1000, 100*df['MedianRA'], linewidths=2, s=2)
# plt.scatter(df['Age']/1000, 100*df['5thPercentileRA'], linewidths=2, s=2)
# plt.scatter(df['Age']/1000, 100*df['95thPercentileRA'], linewidths=2, s=2)
# plt.scatter(df['Age']/1000, 100*df['MeanRA'], linewidths=2, s=2)
plt.plot(df['Age']/1000, 100*df['MedianRA'], marker='o', linewidth=1, markersize=2)
plt.plot(df['Age']/1000, 100*df['5thPercentileRA'], marker='o', linewidth=1, markersize=2)
plt.plot(df['Age']/1000, 100*df['95thPercentileRA'], marker='o', linewidth=1, markersize=2)
plt.plot(df['Age']/1000, 100*df['MeanRA'], marker='o', linewidth=1, markersize=2)
plt.title('Rock Abundance Evolution')
plt.xlabel('Age (Ga)')
plt.ylabel('Fractional Rock Abundance (%)')
plt.legend(['Median RA','5th Percentile','95th Percentile','Mean RA'], loc='upper right')
plt.savefig("Fig2b.png", dpi=600)
plt.show()

axes = plt.gca()
axes.set_ylim([0,2.0])
# axes.set_xlim([0,40000])
# plt.scatter(df['MedianGridcode(freq)'], 100*df['MedianRA'], linewidths=2, s=2)
# plt.scatter(df['MedianGridcode(freq)'], 100*df['5thPercentileRA'], linewidths=2, s=2)
# plt.scatter(df['MedianGridcode(freq)'], 100*df['95thPercentileRA'], linewidths=2, s=2)
# plt.scatter(df['MedianGridcode(freq)'], 100*df['MeanRA'], linewidths=2, s=2)
plt.plot(df['MedianGridcode(freq)'], 100*df['MedianRA'], marker='o', linewidth=1, markersize=2)
plt.plot(df['MedianGridcode(freq)'], 100*df['5thPercentileRA'], marker='o', linewidth=1, markersize=2)
plt.plot(df['MedianGridcode(freq)'], 100*df['95thPercentileRA'], marker='o', linewidth=1, markersize=2)
plt.plot(df['MedianGridcode(freq)'], 100*df['MeanRA'], marker='o', linewidth=1, markersize=2)
plt.title('Rock Abundance Evolution')
plt.xlabel('Frequency(n(800m-5km)) in $10^6$ $km^2$')
plt.ylabel('Fractional Rock Abundance (%)')
plt.legend(['Median RA','5th Percentile','95th Percentile','Mean RA'], loc='upper right')
plt.savefig("Fig2a.png", dpi=600)
plt.show()
