question: D3 Q1
This commit is contained in:
parent
2a6fc39dc0
commit
3207c3f51f
|
|
@ -35,16 +35,19 @@ else:
|
|||
data = meas_data
|
||||
|
||||
|
||||
################################################################################
|
||||
################## Question 1 ##################################################
|
||||
################################################################################
|
||||
|
||||
# Construct a dataframe and pivot it to obtain a dataframe with a column per unit, and a row per timestamp.
|
||||
df = pd.DataFrame.from_records(data)
|
||||
df_pivot = df.pivot_table(values='value', columns='unit', index='time')
|
||||
|
||||
|
||||
# Plot the data. Note, that the data will mostly not be plotted with lines.
|
||||
plt.ion() # Turn interactive mode on
|
||||
plt.figure()
|
||||
ax1 = plt.subplot(211) # Make two separate figures
|
||||
ax2 = plt.subplot(212)
|
||||
df_pivot[[c for c in df_pivot.columns if "_p" in c]].plot(marker='.', ax=ax1, linewidth=3)
|
||||
df_pivot[[c for c in df_pivot.columns if "_q" in c]].plot(marker='.', ax=ax2, linewidth=3)
|
||||
df_pivot['pcc_p'].plot(marker='.', ax=ax1, linewidth=3)
|
||||
df_pivot['pcc_q'].plot(marker='.', ax=ax1, linewidth=3)
|
||||
plt.show(block=True)
|
||||
|
|
|
|||
Loading…
Reference in New Issue