
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How can Bokeh be used to visualize multiple bar plots in Python?
Bokeh is a Python package that helps in data visualization. It is an open source project. Bokeh renders its plot using HTML and JavaScript. This indicates that it is useful while working with web-
Bokeh converts the data source into a JSON file. This file is used as an input to BokehJS, which is a JavaScript library. This BokehJS is written in TypeScript that helps render visualization on modern browsers.
Dependencies of Bokeh
Numpy Pillow Jinja2 Packaging Pyyaml Six Tornado Python−dateutil
Installation of Bokeh on Windows command prompt
pip3 install bokeh
Installation of Bokeh on Anaconda prompt
conda install bokeh
Let us see an example −
Example
from bokeh.plotting import figure, output_file, show from bokeh.transform import dodge labs = ['label_1', 'label_2', 'label_3'] vals = ['val_1','val_2','val_3'] my_data = {'labs':labs, 'val_1':[2,5,11], 'val_2':[34,23,1], 'val_3':[25, 34, 23] } fig = figure(x_range = labs, plot_width = 300, plot_height = 300) fig.vbar(x = dodge('labs', -0.25, range = fig.x_range), top = 'val_1', width = 0.2,source = my_data, color = "green") fig.vbar(x = dodge('labs', 0.0, range = fig.x_range), top = 'val_2', width = 0.2, source = my_data,color = "cyan") fig.vbar(x = dodge('labs', 0.25, range = fig.x_range), top = 'val_3', width = 0.2,source = my_data,color = "blue") show(fig)
Output
Explanation
The required packages are imported, and aliased.
The figure function is called along with plot width and height.
The data is defined in lists.
The ‘output_file’ function is called to mention the name of the html file that will be generated.
The ‘vbar’ function present in Bokeh is called, along with data.
The ‘show’ function is used to display the plot.
- Related Articles
- How can Bokeh be used to visualize bar plot in Python?
- How can Bokeh library be used to visualize stacked bar charts in Python?
- How can Bokeh library be used to plot horizontal bar plots using Python?
- How can Bokeh be used to visualize multiple shapes on a plot in Python?
- How can Bokeh library be used to visualize twin axes in Python?
- How can Seaborn library be used to visualize point plots in Python?
- How can Bokeh be used to visualize different shapes of data points in Python?
- How can Matplotlib be used to create multiple plots iteratively in Python?
- How can multiple lines be visualized using Bokeh Python?
- How can Bokeh be used to generate sinusoidal waves in Python?
- How can Bokeh be used to generate patch plot in Python?
- How can Pygal be used to visualize a treemap in Python?
- How can bar graphs be visualized using Bokeh?
- How can factorplot be used in Seaborn to visualize data in Python?
- How can Bokeh be used to generate scatter plot using Python?
