From 3207c3f51f1a732794f2b0cf073c57bf36f3de63 Mon Sep 17 00:00:00 2001 From: DBras Date: Mon, 10 Jun 2024 11:45:01 +0200 Subject: [PATCH] question: D3 Q1 --- demo_plotter.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/demo_plotter.py b/demo_plotter.py index b876c8e..991152b 100755 --- a/demo_plotter.py +++ b/demo_plotter.py @@ -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)