首页 > 解决方案 > 具有分类数据和条形位置控制的 Bokeh vbar

问题描述

我正在尝试制作一个 vbar 散景图,我可以在其中为分类数据添加标签并控制条形的位置。我尝试了以下方法:

# importing the modules 
from bokeh.plotting import figure, output_file, show 
   
# file to save the model 
output_file("gfg.html") 
   
# instantiating the figure object 
graph = figure() 

# x-coordinates to be plotted 
x = [1, 2, 3, 5, 8] 

# x-coordinates of the top edges 
top = [1, 2, 3, 4, 5] 

# tick labels 
tick_labels = ["Team 1", "Team 2", "Team 3", "Team 4", "Team 5"]

# plotting the graph 
graph.vbar(x, top = top, width = 0.6)

# displaying the model 
show(graph)

在此处输入图像描述 结果可以控制条形的位置,但不能控制 x 轴上的“团队”标签。我尝试了不同的组合,我可以获得标签,但失去了对条形的放置控制。非常感谢任何帮助或建议。吉诺

标签: pythonbokeh

解决方案


推荐阅读