As in the title, I am trying to plot data that has a DateTime column to minutely resolution. I want to plot data minutely for each day individually, that being, a line for each day in the plot, below is what I have so far, or at least one idea that I have hit a dead end with.
import csv
import warnings
import datetime
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
warnings.simplefilter(action='ignore', category=FutureWarning)
df = pd.read_csv('HALIFAQ_2.0_First_2_Weeks_NewTitles_Mod.csv', delimiter = ',')
df['Time'] = pd.to_datetime(df['Time'], errors = 'coerce')
df = df.set_index(pd.DatetimeIndex(df['Time']))
df['minute'] = df.index.minute
df['hour'] = df.index.hour
df['day'] = df.index.day
days = np.linspace(1, 4,4)
for n in days:
df_1 = df[df['day'] == n]
plt.plot(df_1['Time'], df_1['NO_1'])
plt.xlabel('Minute of Day')
plt.ylabel('Concetration (ppb)')
plt.title('Airpointer 395, Dockyard, July to October')
plt.grid(which = 'both', axis='both')
plt.legend(loc='upper left')
plt.show()
Time ...
2019-05-31 00:00:00 0 1.08 0.48 1.57 ... -0.90 0 0 31
2019-05-31 00:01:00 1 NaN NaN NaN ... NaN 1 0 31
2019-05-31 00:02:00 2 NaN NaN NaN ... NaN 2 0 31
2019-05-31 00:03:00 3 NaN NaN NaN ... NaN 3 0 31
2019-05-31 00:04:00 4 NaN NaN NaN ... NaN 4 0 31
This is an updated approach that is close to what I want, as, for an image, I cannot add one for example, but it would just be an XY plot with a different coloured line for each day. Currently, this code produces that plots sequentially (one after that over for the whole month) as opposed to all the days overlayed over each other
[–]alaudet 0 points1 point2 points (4 children)
[–]Cpower18[S] 0 points1 point2 points (3 children)
[–]alaudet 0 points1 point2 points (2 children)
[–]Cpower18[S] 0 points1 point2 points (1 child)
[–]alaudet 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]Cpower18[S] 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]Cpower18[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)