Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic range issue when updating data on ScatterGL #1661

Open
astrofrog opened this issue Oct 29, 2024 · 6 comments
Open

Dynamic range issue when updating data on ScatterGL #1661

astrofrog opened this issue Oct 29, 2024 · 6 comments

Comments

@astrofrog
Copy link
Contributor

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

@astrofrog
Copy link
Contributor Author

@maartenbreddels - just for the record as I think you originally implemented ScatterGL?

@maartenbreddels
Copy link
Member

I have trouble reproducing this. Which versions of bqplot and jupyter (notebook or lab?) are you using?

I wonder if it could be a hardware issue, do you see the same issue on PyCafe

(If so, it could be a hardware issue)

@rosteen
Copy link

rosteen commented Nov 12, 2024

I was on:

jupyterlab 4.2.5
bqplot 0.12.43
bqplot-gl 0.0.0
bqplot-image-gl 1.5.0

Did you try running the LCViz example notebook? That's also a way to reproduce (the flattening step leads to a flat featureless plot at 1, see the LCViz issue linked above).

@astrofrog
Copy link
Contributor Author

It works fine for me on PyCafe but not in Jupyter Lab locally (on the same machine)

@maartenbreddels
Copy link
Member

Apparently this depends on the hardware as I found out using this example

(now with the button, we make the change happen somewhat later).

This shows the aliasing on a M1 Pro, but not on a M1 Max (which I have).

    vec3 center = mix(vec3(x_previous, y_previous, 0), vec3(x, y, 0), animation_time);

On some hardware, even when animation_time is 0, the magnitude of y_previous had an effect on center.y!

I should have a fix out early next week.

@rosteen
Copy link

rosteen commented Nov 22, 2024

Interesting, thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants