Py.Cafe

maartenbreddels/

bqplot-test

Interactive Scatter Plot Demo - bqplot

DocsPricing
  • app.py
  • bqplot-0.12.43-py2.py3-none-any.whl
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import numpy as np
from bqplot import (
    Axis,
    LinearScale,
    ScatterGL,
    Figure,
    PanZoom,
)
import ipywidgets as widgets
from IPython.display import display

sc_x = LinearScale()
sc_y = LinearScale()

scatt = ScatterGL(
    x=np.linspace(98.3, 98.4, 100),
    y=np.linspace(-1e6, 2e16, 100),
    scales={"x": sc_x, "y": sc_y},
)
ax_x = Axis(scale=sc_x, label="x")
ax_y = Axis(scale=sc_y, orientation="vertical", tick_format="0.0f", label="y")
panzoom = PanZoom(scales={"x": [sc_x], "y": [sc_y]})

figure = Figure(marks=[scatt], axes=[ax_x, ax_y])


def on_click(btn):
    eps = 1e-4
    scatt.y = np.linspace(1.0-eps, 1.0+eps, 100)
    sc_y.min = 1-2*eps
    sc_y.max = 1+2*eps


button = widgets.Button(description="Show precision error")
button.on_click(on_click)

page = widgets.VBox([figure, button])
requirements.txt
1
2
3
4
5
solara
# with this version, we should not see a problem
https://py.cafe/files/maartenbreddels/bqplot-test/bqplot-0.12.43-py2.py3-none-any.whl
# the released version might compress it to a dot
#bqplot