假设我有以下数据:
结果是一个空图。以下也不起作用:
import random
import pandas as pd
numbers = random.sample(range(1,50), 12)
d = {'month': range(1,13),'values':numbers}
df = pd.DataFrame(d)
我正在使用bokeh来可视化结果:
p = figure(plot_width=400, plot_height=400)
p.line(df['month'], df['values'], line_width=2)
output_file('test.html')
show(p)
结果还可以。我想让x轴表示一个月(1:一月,2:二月...)。我正在执行以下操作将数字转换为月份:import datetime
df['month'] = [datetime.date(1900, x, 1).strftime('%B') for x in df['month']]
p = figure(plot_width=400, plot_height=400)
p.line(df['month'], df['values'], line_width=2)
show(p)
结果是一个空图。以下也不起作用:
p.xaxis.formatter = DatetimeTickFormatter(format="%B")
有什么办法能够越过它吗?