
- 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 generate scatter plot using 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. 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
Let us see an example −
Example
from bokeh.plotting import figure, output_file, show fig = figure(plot_width = 500, plot_height = 400) fig.scatter([1,3,7,5,4,9], [6,5,9,8,0,1], marker = "circle", size = 20, fill_color = "grey") output_file('scatterplot.html') show(fig)
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 ‘scatter’ 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 generate patch plot in Python?
- How can Bokeh be used to generate candle stick plot in Python?
- How can Bokeh be used to generate sinusoidal waves in Python?
- How can Bokeh library be used to plot horizontal bar plots using Python?
- How can Bokeh be used to visualize bar plot in Python?
- How can Matplotlib be used to create three-dimensional scatter plot using Python?
- How can Bokeh library be used to generate line graphs in Python?
- How can Bokeh be used to create step line plot in Python?
- How can Bokeh be used to create a color scatter plot that shows data when hovering over points in Python?
- How can Seaborn library be used to display a Scatter Plot in Python?
- How can Bokeh be used to visualize multiple shapes on a plot in Python?
- How can grid plot in Bokeh library be created with Python?
- How can Tensorflow be used to plot the results using Python?
- How can Keras be used to plot the model using Python?
- How can Bokeh be used to visualize multiple bar plots in Python?
