LensPy extends Plotly's Dash to allow you to plot very large datasets (millions of points) while ensuring that figures are still fast, fluid, and responsive.
This is achieved by adjusting the visible data based on the position of the viewport and how zoomed in the figure is. When you're zoomed out, only a subset of the data is shown. When you zoom in, LensPy will render more detail in your plot. By doing this, LensPy can build dynamic figures of very large datasets without overwhelming the browser when viewing the figures.
- Ability to specify number of points to display at once
- Ability to define a custom function for downsampling data
- Ability to run in Jupyter notebooks
- Ability to use with Dash applications
Install LensPy using pip
pip install lenspy
Use LensPy by passing any Figure to the DynamicPlot constructor.
import numpy as np
import plotly.graph_objects as go
from lenspy import DynamicPlot
# First, let's create a very large figure
x = np.arange(1, 11, 1e-6)
y = 1e-2*np.sin(1e3*x) + np.sin(x) + 1e-3*np.sin(1e10*x)
fig = go.Figure(data=[go.Scattergl(x=x, y=y)])
fig.update_layout(title=f"{len(x):,} Data Points.")
# Use DynamicPlot.show to view the plot
plot = DynamicPlot(fig)
plot.show()
# Plot will be available in the browser at http://127.0.0.1:8050/
You can still access any of the Plotly Figure methods/attributes and modify them as needed.
LensPy starts a Flask web server, therefore plots won't be rendered in your notebook as widget. You can always access your plot in a seperate tab (default url is http://127.0.0.1:8050/)
For the full reference and detailed information, please see the documentation.
Copyright (c) 2022 Seran Thirugnanam under the MIT License.
Help is always welcome. Feel free to open issues or PRs if there is a feature missing, or a bug to be addressed.