- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can Bokeh be used to visualize different shapes of data points 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-based dashboards. It helps in communicating the quantitative insights to the audience effectively.
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.
Matplotlib and Seaborn produce static plots, whereas Bokeh produces interactive plots. This means when the user interacts with these plots, they change accordingly.
Plots can be embedded as output of Flask or Django enabled web applications. Jupyter notebook can also be used to render these plots.
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
The ‘figure’ function contains multiple functions, and using this, vectorised glyphs of different shapes (circle, square, rectangle) can be drawn.
Example
from bokeh.plotting import figure, output_file, show plot = figure(plot_width = 300, plot_height = 300) plot.circle(x = [1, 4, 6], y = [3,7,8], size = 20, fill_color = 'red') plot.circle_cross(x = [2,4,5], y = [3,8,11], size = 20, fill_color = 'black',fill_alpha = 0.2, line_width = 2) plot.circle_x(x = [5,3,2], y = [2,1,7], size = 20, fill_color = 'green',fill_alpha = 0.6, line_width = 2) show(plot)
Output
Explanation
The required packages are imported, and aliased.
The figure function is called along with plot width and height.
The ‘output_file’ function is called to mention the name of the html file that will be generated.
The ‘circle’, ‘circle_cross’, and ‘circle_x’ functions present in Bokeh are called, along with data.
The ‘show’ function is used to display the plot.
- Related Articles
- How can Bokeh be used to visualize multiple shapes on a plot in Python?
- How can Bokeh be used to visualize bar plot in Python?
- How can Bokeh be used to visualize multiple bar plots in Python?
- How can Bokeh library be used to visualize twin axes in Python?
- How can Bokeh library be used to visualize stacked bar charts in Python?
- How can factorplot be used in Seaborn to visualize data in Python?
- How can Tensorflow be used to visualize the data using Python?
- How can FacetGrid be used to visualize data in Python Seaborn Library?
- How can the countplot be used to visualize data in Python Seaborn Library?
- How can Bokeh be used to create a color scatter plot that shows data when hovering over points in 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 Tensorflow and pre-trained model be used to visualize the data using Python?
- How can Tensorflow be used with estimators to visualize the titanic data?
