我有一个简单的hbar图的代码,它被精简为我认为应该是的,但显示为一个白框。(我可以得到一个简单的线图示例,这样我就知道标题设置正确了。)
from bokeh.embed import components
from bokeh.plotting import figure
fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
counts = [5, 3, 4, 2, 4, 6]
p = figure(plot_height=250, title="Fruit counts",
toolbar_location=None, tools="")
p.hbar(y=fruits, right=counts)
data, div = components(p)
控制台中的错误是“[Bokeh]无法设置初始范围” 如果有人能给我指一下需要添加的文档,那会很有帮助
由于您是working with categorical data,因此需要为
y_range
分配一个FactorRange
。这可以通过p.y_range=FactorRange(factors=fruits)
或其速记版本p.x_range=fruits
完成。以下示例正确显示了该图:
相关问题 更多 >
编程相关推荐