我有一些重大的问题,建立我的第一个线图,目前我一直在工作和研究我的错误很长时间用尽一切努力。在
我有下面的日期时间示例数据与销售在以下格式。数据正在从MySQL数据库导入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
我正在努力工作的线图,并想完成一个线图在博克和matplotlib。我的第一个选择是bokeh线图示例here。在
我使用的matplotlib脚本在下面注释掉了。在
我收到了很多很多错误,我会列出下面的错误。错误的概要使我相信我的日期时间格式不正确,我不理解matplotlib中格式化的Auto datetime。
我还使用正则表达式对日期进行排序并以正确的格式打印日期。在
^{pr2}$
bokeh示例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)
目前的错误,虽然我已经处理了数百个错误。“的”行.html“打开一个盒子,但没有行,日期或销售。在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
这是我使用的matplotlib代码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()
"""
有人能给我指一下正确的方向吗。有人能帮助您正确使用日期时间bokeh或matplotlib格式吗
需要执行正确的线图,并能有人解释当前的错误。在