Skip to content

Dynamic range issue when updating data on ScatterGL #1661

@astrofrog

Description

@astrofrog

When updating x or y on a ScatterGL mark, the display will not look good if the new values are at a significantly different order of magnitude compared to the original values.

The following example demonstrates the issue:

import numpy as np
from bqplot import (
    Axis,
    LinearScale,
    ScatterGL,
    Figure,
    PanZoom,
)
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, 2e6, 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])
display(figure)

y = np.random.uniform(0.9, 1.1, 100)
y[0] = np.nan
scatt.y = y

sc_y.min = 0.0
sc_y.max = 2.0

If run in a notebook in a single cell, this gives:

image

The values appear to be discretised. Showing the figure in a new cell works fine:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions