I am having some major issues building my first ever line graph and currently I have been working and researching my errors for a long time exhausting all efforts.
I have the following date time example data with sales in the following format. The data is being imported from my MySQL database
2015-12-30 01:58:00 10
2015-12-30 01:59:00 16
2015-12-30 02:00:00 21
2015-12-30 02:01:00 5
2015-12-30 02:02:00 2
2015-12-30 02:03:00 4
2015-12-30 02:04:00 11
2015-12-30 02:06:00 5
2015-12-30 02:07:00 10
I am working hard on line graphs and would like to complete a line graph in both bokeh and matplotlib. My first choice is the bokeh line graph example here.
The matplotlib scripts I am using are commented out below.
I have received many, many errors and will list the errors below as I go. The general synopsis of the errors leads me to believe my datetime is not formatted correctly and I do not understand the Auto datetime formatted in matplotlib. I have also been using regular expressions to sort the date and print the date in the correct format.
#row[0] is the date
#row[1] is the sales
2015-12-30 02:09:00 1
2015-12-30 02:10:00 3
2015-12-30 02:12:00 2
2015-12-30 02:13:00 1
2015-12-30 02:14:00 18
2015-12-30 02:15:00 1
2015-12-30 02:16:00 10
2015-12-30 02:17:00 2
bokeh example
import numpy as np
from bokeh.plotting import figure, output_file, show
import utils
from bokeh.io import output_notebook, show
from bokeh.plotting import figure
# the import from MYSQL works great and data prints 100% works great
db = MySQLdb.connect("all my database stuff")
cur = db.cursor()
cur.execute("SELECT Statement")
#row[0] is the date in the format above "2015-12-30 02:09:00"
#row[1] is the sales in the format above "1"
try:
for row in cur.fetchall():
date = row[0]
sales = row[1]
#regex to strip date hypens and colons replace with spaces
#date_clean = re.sub('[^A-Za-z0-9]+', '', date)
print date,
print sales
#print date_clean prints with no extra characters
except:
print "error: unable to fetch data"
# prepare some data
x = 'date'
#x = 'date_clean'
y = 'sales'
# output to static HTML file
output_file("lines.html", title="line plot example")
# create a new plot with a title and axis labels
p = figure(title="example chart", x_axis_label='x', y_axis_label='y')
# add a line renderer with legend and line thickness
p.line(x, y, legend="Temp.", line_width=2)
# show the results
show(p)
Current errors although I have worked through hundreds of errors. The "lines.html" opens up with a box but no line, dates or sales.
No handlers could be found for logger "/usr/local/lib/python2.7/dist-packages/bokeh/validation/check.pyc"
(process:20113): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
here is the matplotlib code I am using
x = date_clean
y = sales
plt.plot_date(x=date_clean, y=sales)
plt.title("example chart")
plt.ylabel("sales")
plt.grid(True)
plt.show()
"""
Can someone point me in the correct directions. Can anyone help with the correct format for the date time bokeh or matplotlib requires to execute a correct line graph and can someone explain the current error.
bokeh, but what is the error you get withmatplotlib?