散景酒吧剧情| [英] Bokeh Bar plot |

查看:51
本文介绍了散景酒吧剧情|的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Python创建bokeh条形图.data2是值

I am trying to Create a bokeh bar chart using Python. The data2 is the values

from bokeh.plotting import figure, output_file, show,hplot
from bokeh.charts import Bar

data2=[65.75, 48.400000000000006, 58.183333333333337, 14.516666666666666]


bar = Bar(values=data2,xlabel="beef,pork,fowl,fish",ylabel="Avg consumtion", width=400)

show(bar)

错误

TypeError: Bar() takes at least 1 argument (1 given)

我在这里做什么错了?

推荐答案

已弃用 bokeh.charts API(包括 Bar ),并于2017年将其从Bokeh中删除.是不受维护和不受支持的,此时不应出于任何原因使用它.可以使用受支持的 bokeh.plotting API完成简单的条形图:

The bokeh.charts API (including Bar) was deprecated and removed from Bokeh in 2017. It is unmaintained and unsupported and should not be used for any reason at this point. A simple bar chart can be accomplished using the well-supported bokeh.plotting API:

from bokeh.plotting import figure, show

categories = ["beef", "pork", "fowl", "fish"]
data = [65.75, 48.4, 58.183, 14.517]

p = figure(x_range=categories)
p.vbar(x=categories, top=data, width=0.9)

show(p)

有关 bokeh.plotting 中对条形图和分类图的极大改进支持的更多信息,请参见广泛的用户指南部分

For more information on the vastly improved support for bar and categorical plots in bokeh.plotting, see the extensive user guide section Handling Categorical Data

这篇关于散景酒吧剧情|的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆