我试图使用散景库在图中绘制一些annular_wedge,但是当我使用x_axis_type =" datetime"在图kargs中,没有绘制任何内容。我的目标是制作像定向风的matlab棒图。
from bokeh.plotting import figure, show
from datetime import datetime
from datetime import timedelta
#x=[1, 2, 3] #some x samples
x = [datetime.today() + timedelta(days=aux) for aux in range(3)] #some datetime samples
y=[1, 2, 1.5]
a=[1.5,3.0,4.5] #some start_angle for wedge_annulus
b=[1.5+0.1,3.0+0.1,4.5+0.1] # some end_angle for wedge_annulus
p = figure(width=400, height=400,x_axis_type="datetime") #when figure is datetime type, there is no plot.
p.annular_wedge(x, y, inner_radius=0.1, outer_radius=0.55,
start_angle=a, end_angle=b ,color="red", alpha=0.6, legend="q")
show(p)
一段时间后,我明白问题应该是x轴的比例,即在datetime中必须提升^ 12。我试图将inner_radius和outer_radius乘以^ 12(datetime - > timestamp),但我仍然遇到麻烦使它工作。
答案 0 :(得分:1)
这是代码的最终版本。现在它按我需要的方式工作。
from bokeh.plotting import figure, show
from datetime import datetime
from datetime import timedelta
x = [(datetime.today() + timedelta(days=aux)) for aux in range(3)] #some datetime samples
y=[1, 2, 1.5]
a=[1.5,3.0,4.5] #some start_angle for annular_wedge
b=[1.5+0.1,3.0+0.1,4.5+0.1] # some end_angle for annular_wedge
p = figure(width=400, height=400,x_axis_type="datetime") #when figure is datetime type, there is no plot.
p.annular_wedge(x, y, inner_radius=0, outer_radius=0.3*(10**8),
start_angle=a, end_angle=b ,color="red", alpha=0.6, legend="q")
show(p)