- 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 to embed an interactive Matplotlib plot on a webpage?
To show a plot on a webpage such that the plot could be interactive, we can take the following steps −
- Install Bokeh and import figure, show, and output_file.
- Configure the default output state to generate the output saved to a file when:func:'show' is called.
- Create a new Figure for plotting.
- Render the images loaded from the given URLs.
- Immediately display a Bokeh object or application.
Example
from bokeh.plotting import figure, show, output_file output_file('image.html') p = figure(x_range=(0, 1), y_range=(0, 1)) p.image_url(url=['bird.jpg'], x=0, y=1, w=0.8, h=0.6) show(p)
Output
When we execute the code, it will show the following image on your default browser.
You can move the image around on the browser, as the plot is interactive
- Related Articles
- How get the (x,y) position pointing with mouse in an interactive plot (Python Matplotlib)?
- Make 3D plot interactive in Jupyter Notebook (Python & Matplotlib)
- How to get an interactive plot of a pyplot when using PyCharm?
- How to embed fonts in PDFs produced by Matplotlib
- How to create custom markers on a plot in Matplotlib
- How to plot a point on 3D axes in Matplotlib?
- How to plot events on time using Matplotlib?
- How to plot a rectangle on a datetime axis using Matplotlib?
- How to plot additional points on the top of a scatter plot in Matplotlib?
- How to plot multiple histograms on same plot with Seaborn using Matplotlib?
- How to place customized legend symbols on a plot using Matplotlib?
- How to show tick labels on top of a matplotlib plot?
- How to plot a dashed line on a Seaborn lineplot in Matplotlib?
- How to a plot stem plot in Matplotlib Python?
- How to display multiple outputs on an HTML webpage using PowerShell?

Advertisements