bqplot
Interactive Demo¶Plotting in JupyterLite
bqplot
can be installed in this deployment (it provides the bqplot federated extension), but you will need to make your own deployment to have access to other interactive widgets libraries.
import micropip
await micropip.install('bqplot==0.12.30')
from bqplot import *
import numpy as np
import pandas as pd
np.random.seed(0)
n = 100
x = list(range(n))
y = np.cumsum(np.random.randn(n)) + 100.
sc_x = LinearScale()
sc_y = LinearScale()
lines = Lines(
x=x, y=y,
scales={'x': sc_x, 'y': sc_y}
)
ax_x = Axis(scale=sc_x, label='Index')
ax_y = Axis(scale=sc_y, orientation='vertical', label='lines')
Figure(marks=[lines], axes=[ax_x, ax_y], title='Lines')
lines.colors = ['green']
lines.fill = 'bottom'
lines.marker = 'circle'
n = 100
x = list(range(n))
y = np.cumsum(np.random.randn(n))
sc_x = LinearScale()
sc_y = LinearScale()
bars = Bars(
x=x, y=y,
scales={'x': sc_x, 'y': sc_y}
)
ax_x = Axis(scale=sc_x, label='Index')
ax_y = Axis(scale=sc_y, orientation='vertical', label='bars')
Figure(marks=[bars], axes=[ax_x, ax_y], title='Bars', animation_duration=1000)
bars.y = np.cumsum(np.random.randn(n))
from bqplot import *
import numpy as np
import pandas as pd
np.random.seed(0)
y1 = np.cumsum(np.random.randn(150)) + 100.
y2 = np.cumsum(np.random.randn(150)) + 100.
y3 = np.cumsum(np.random.randn(150)) + 100.
y4 = np.cumsum(np.random.randn(150)) + 100.
sc_x = LinearScale()
sc_y = LinearScale()
lines = Lines(x=np.arange(len(y1)), y=[y1, y2, y3, y4],
scales={'x': sc_x, 'y': sc_y})
ax_x = Axis(scale=sc_x, label='Index')
ax_y = Axis(scale=sc_y, orientation='vertical', label='lines')
Figure(marks=[lines], axes=[ax_x, ax_y], title='Lines')