Browse Source

create daily-totals.py script.

This script produces a line chart, using Bokeh, displaying the daily totals for
both Light Meters. The data is process from /data and the chart is written to
the /output directory -- as a HTML file.
master
Craig Oates 1 year ago
parent
commit
aa27dc8519
  1. 44
      daily-totals.py

44
daily-totals.py

@ -0,0 +1,44 @@
from bokeh.plotting import figure, output_file, save, show
from bokeh.models import Legend
import pandas as pd
import numpy as np
from bokeh.models import ColumnDataSource
x_vals = []
y_vals = []
file_data = pd.read_csv("data/light-meter-1-daily-totals.csv", sep=",",
header=None, index_col=False, dtype='unicode')
for row in file_data.values[1:] :
x_vals.append(row[0])
y_vals.append(row[1])
x_vals2 = []
y_vals2 = []
file_data2 = pd.read_csv("data/light-meter-2-daily-totals.csv", sep=",",
header=None, index_col=False, dtype='unicode')
for row in file_data2.values[1:] :
x_vals2.append(row[0])
y_vals2.append(row[1])
data = {'x_values': pd.to_datetime(x_vals),
'y_values': np.asarray(y_vals).astype(int),
'x_values2': pd.to_datetime(x_vals2),
'y_values2': np.asarray(y_vals2).astype(int)}
source = ColumnDataSource(data=data)
p = figure(title="Total Daily Reading for Light Meters",
x_axis_label="Date",
y_axis_label="Total Readings",
x_axis_type='datetime',
sizing_mode="stretch_both")
p.axis.major_label_text_font_size = "12px"
p.axis.major_label_standoff = 10
p.line(x='x_values', y='y_values', source=source,
line_color="blue", legend_label="Light Meter 1 (Andy)")
p.line(x='x_values2', y='y_values2', source=source,
line_color="orange", legend_label="Light Meter 2 (Tony)")
output_file("output/daily-totals.html")
save(p)
Loading…
Cancel
Save