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])