- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 draw random rectangles that have a specific alignment using Python?
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
Arbitrary rectangles can be drawn by specifying centre point, height, width, and angle. This is achieved using the ‘rect’ function. Following is an example −
from math import pi from bokeh.plotting import figure, output_file, show output_file('rectanglesRandom.html') p = figure(plot_width=400, plot_height=400) p.rect(x=[1, 3, 5, 7], y=[1, 3, 5, 7], width=0.2, height=50, color="#CAB2D6", angle=pi/3, height_units="screen") show(p)
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 ‘rect’ function present in Bokeh is called, along with data.
The ‘show’ function is used to display the plot.
- How can axis aligned rectangles be visualized using Python and Bokeh?
- How can Bokeh be used to generate scatter plot using Python?
- How can Bokeh library be used to plot horizontal bar plots using 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 Bokeh be used to visualize bar plot in Python?
- How can Bokeh library be used to generate line graphs 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 generate candle stick plot in Python?
- How can Bokeh be used to create step line plot in Python?
- How can Bokeh be used to visualize multiple shapes on a plot in Python?
- How can multiple lines be visualized using Bokeh Python?
- How can Bokeh library be used to visualize stacked bar charts in Python?
- How can a Beizer curve be visualized using Bokeh?