Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bokeh Bar plot |

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)

Error

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

What am I doing wrong Here?

like image 617
Kishan Jangam Avatar asked May 24 '26 11:05

Kishan Jangam


1 Answers

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)

enter image description here

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

like image 94
bigreddot Avatar answered May 27 '26 01:05

bigreddot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!