--The one that runs in the same directory as the program created in the following article
%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)
--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