The one that graphs the one that got the fitbit data from the server

Overview

--The one that runs in the same directory as the program created in the following article

code


%matplotlib inline
import os
import sys
import numpy as np
import pandas as pd
import plotly
import matplotlib.pyplot as plt
plotly.offline.init_notebook_mode(connected=False)

#Specify frequency and date to plot
FREQ = '1sec' #1sec,1min,15min
DATE = '2017-01-29' #YYYY-MM-DD

#Generate filename and directory path from frequency and date
#Abnormal termination if not the specified frequency
#Correct if the relative path is incorrect
FILE = './HR_%s_%s.csv' % ( DATE, FREQ )
DIR = './%s' % FREQ
if not FREQ in {'1sec','1min','15min'}:sys.exit(1)
if not os.path.exists(DIR):DIR = '.%s' % DIR

#Move working directory to DIR
#Abnormal termination if FILE does not exist
os.chdir(DIR)
if not os.path.exists(FILE):sys.exit(1)

#Read CSV file and plot graph
raw = pd.read_csv(FILE,header=None,skiprows=1,names=['Time','HR'])
data = [ plotly.graph_objs.Scatter(x=raw['Time'], y=raw['HR'], name='test') ]
fig = plotly.graph_objs.Figure(data=data)
plotly.offline.iplot(fig)

Run

--Start Jupyter with "jupyter notebook" or "ipython notebook" in the terminal (it is easier to move to the directory where the data is stored with the cd command first) --Click New on the Jupyter home screen to create a Python 2 Notebook --Execute the above code --Graph appears --Specify the data frequency and date with FREQ and DATE (Please get the data from the cloud in advance)


Will be edited later

Recommended Posts

The one that graphs the one that got the fitbit data from the server
The guy who gets fitbit data from the server
I got lost in the maze
The one who is not on DVD
The one that displays the progress bar in Python
The guy who gets fitbit data from the server
Send log data from the server to Splunk Cloud
I searched for railway senryu from the data
One liner that lists the colors of matplotlib
POST images from ESP32-CAM (MicroPython) to the server
The one that displays the progress bar in Python
The transition of baseball as seen from the data
Extract rows that meet the conditions from Excel containing date data (% Y /% m /% d)