I have two csv files that have been generated on one chronological basis during my recording (they both have a timestamp column based on one clock). I want to plot my data in matplotlib (or elsewhere using python, if you have a better suggestion).
On my primary x axis, I want to have the general continuous timestamps (from csv file 1).
On my y axis I need the recordings of my desired variable (from csv file 1).
On my secondary x axis, I need to have my experiment events or annotations (from csv file 2), right at the timestamps (ticks) when they happened.
I try to plot all of these, this way:
ticks = annotations_pd_frame['timestamp']
labels = annotations_pd_frame['label']
fig, ax1 = plt.subplots()
ax2 = ax1.twiny()
fig.set_figheight(5)
fig.set_figwidth(25)
ax1.yaxis.grid()
plt.xticks(ticks, labels)
plt.plot(pupil_data_in_trial_eye0['pupil_timestamp'].loc[pupil_data_in_trial_eye0['trial'] == trial_label], pupil_data_in_trial_eye0['diameter_3d'].loc[pupil_data_in_trial_eye0['trial'] == trial_label])
plt.plot(pupil_data_in_trial_eye1['pupil_timestamp'].loc[pupil_data_in_trial_eye1['trial'] == trial_label], pupil_data_in_trial_eye1['diameter_3d'].loc[pupil_data_in_trial_eye1['trial'] == trial_label])
plt.legend(['eye0', 'eye1'])
ax1.set_xlabel('Timestamps [s]')
ax1.set_ylabel('Diameter [mm]')
plt.title('Pupil Diameter in ' + str(label) )
plt.grid(b=True)
An example of the csv files is here : https://gist.github.com/Zahra-on-Github/aa67a3e309fa66582a118f5c08509f77
Any ideas what I'm doing wrong?