image_output_1.png
import matplotlib.pyplot as plt

fig, ax = plt.subplots(2,1, figsize=(20,10))
ax[0].plot(train['acoustic_data'].values[::100], color='g')
ax[0].set_title("Acoustic data for 1% sample data")
ax[0].set_xlabel("Index")
ax[0].set_ylabel("Acoustic Data Signal");
ax[1].plot(train['time_to_failure'].values[::100], color='b')
ax[1].set_title("Time to Failure for 1% sample data")
ax[1].set_xlabel("Index")
ax[1].set_ylabel("Time to Failure in ms");

def plotAroundPoints(start, end, ith):
    fig, ax1 = plt.subplots(figsize=(8, 4))
    plt.title('Trends of acoustic_data and time_to_failure around the {} earthquake'.format(ith))
    plt.plot(train['acoustic_data'].values[start:end:50], color='b')
    ax1.set_ylabel('acoustic_data', color='b')
    plt.legend(['acoustic_data'])
    ax2 = ax1.twinx()
    plt.plot(train['time_to_failure'].values[start:end:50], color='g')
    ax2.set_ylabel('time_to_failure', color='g')
    plt.legend(['time_to_failure'], loc=(0.75, 0.1))
plotAroundPoints(0, 30000000, 'first')
plotAroundPoints(30000000, 60000000, 'second')
plotAroundPoints(90000000, 120000000, 'third')
plotAroundPoints(125000000, 155000000, 'fourth')
plotAroundPoints(170000000, 200000000, 'fifth')
plotAroundPoints(200000000, 230000000, 'sixth')
plotAroundPoints(225000000, 255000000, 'seventh')
plotAroundPoints(285000000, 315000000, 'eigth')
plotAroundPoints(325000000, 355000000, 'ninth')
plotAroundPoints(360000000, 390000000, 'tenth')
plotAroundPoints(405000000, 455000000, 'eleventh')
plotAroundPoints(440000000, 470000000, 'twelvth')
plotAroundPoints(480000000, 510000000, 'thirteenth')
plotAroundPoints(510000000, 540000000, 'fourteenth')
plotAroundPoints(560000000, 590000000, 'fifteenth')
plotAroundPoints(605000000, 635000000, 'sixteenth')