Roy*_*lue 2 python datetime bar-chart bokeh
我想使用bokeh绘制vbar图,其中x轴使用日期时间,y轴使用分类值。
最初,我尝试如下绘制圆形图:
import pandas as pd
from datetime import datetime
from dateutil.parser import parse
from bokeh.plotting import figure, show, output_notebook
from bokeh.models.ranges import FactorRange
x = pd.Series(['2017/1/1', '2017/1/2', '2017/1/3', '2017/1/4']).map(lambda x: parse(x))
y = ["a", "b", "c", "a"]
p = figure(x_axis_type='datetime', y_range=list(set(y)), plot_width=400, plot_height=200)
p.circle(x, y, size=10, line_color="blue", line_width=1)
show(p)
Run Code Online (Sandbox Code Playgroud)
看起来不错,除了它不是条形的。
接下来,我尝试了以下代码,但未显示任何图:
x = pd.Series(['2017/1/1', '2017/1/2', '2017/1/3', '2017/1/4']).map(lambda x: parse(x))
y = ["a", "b", "c", "a"]
p = figure(x_axis_type='datetime', y_range=list(set(y)), plot_width=400, plot_height=200)
p.vbar(x=x, bottom=0, top=y, width=0.1, color="blue")
show(p)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1157 次 |
| 最近记录: |