Skip to content

Instantly share code, notes, and snippets.

@brinnaebent
Created November 17, 2020 14:25
Show Gist options
  • Save brinnaebent/8d8d8b16005d38784351e74d37fdb2a7 to your computer and use it in GitHub Desktop.
Save brinnaebent/8d8d8b16005d38784351e74d37fdb2a7 to your computer and use it in GitHub Desktop.
# Calculate the mean and standard deviation of glucose. We will draw 3 lines on the plot: The mean, 1 standard deviation above the mean, and 1 standard deviation below the mean.
glucose_mean = np.mean(df['Glucose'])
up = np.mean(df['Glucose']) + np.std(df['Glucose'])
dw = np.mean(df['Glucose']) - np.std(df['Glucose'])
# Same plot as above
plt.figure(figsize=(25,5))
plt.rcParams.update({'font.size': 20})
plt.plot(df['DateTime'], df['Glucose'], '.', color = '#1f77b4')
# Plot 3 horizontal lines
plt.axhline(y=glucose_mean, color='red', linestyle='-')
plt.axhline(y=up, color='pink', linestyle='-')
plt.axhline(y=dw, color='pink', linestyle='-')
# Add a label
plt.ylabel('Glucose')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment