- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- 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 generate sinusoidal waves 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.

Visualizing data is an important steps since it helps understand what is going on in the data without actually looking at the numbers and performing complicated computations.

Bokeh can be easily used in conjunction with NumPy, Pandas, and other Python packages. It can be used to produce interactive plots, dashboards, and so on.

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

Let us see how Bokeh can be used to generate line graphs

from bokeh.plotting import figure, output_file, show import numpy as np import math x = np.arange(0, math.pi*4, 0.1) y = np.sin(x) output_file("sample.html") p = figure(title = "A simple sine wave ", x_axis_label = 'x', y_axis_label = 'y') p.line(x, y, legend = "sine", line_width = 2) show(p)

## Output

## Explanation

The required packages are imported, and aliased.

The data is generated using NumPy library.

The sine function is defined.

The figure function is called.

The ‘output_file’ function is called to mention the name of the html file that will be generated.

The ‘line’ function present in Bokeh is called.

The ‘show’ function is used to display the plot.

- Related Questions & Answers
- How can Bokeh be used to generate patch plot in Python?
- How can Bokeh be used to generate scatter plot using Python?
- How can Bokeh library be used to generate line graphs in Python?
- How can Bokeh be used to generate candle stick 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 be used to create step line 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 Pygal be used to generate line plots in Python?
- How can Pygal be used to generate box plots in Python?
- How can Pygal be used to generate dot plots in Python?
- How can Pygal be used to generate Funnel plots in Python?
- How can Pygal be used to generate Gauge plots in Python?