Py.Cafe

maartenbreddels/

glue-jupyter-scatter-plot

Glue-Jupyter Scatter Plot Visualization

DocsPricing
  • app.py
  • 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
from random import randint
from glue.core import Data, BaseCartesianData
from glue_jupyter import jglue
from glue_jupyter.bqplot.histogram import BqplotHistogramView 
from glue_jupyter.bqplot.scatter import BqplotScatterView

app = jglue()
N = 50
x = [randint(0, 50) for _ in range(N)]
y = [randint(0, 50) for _ in range(N)]
z = [randint(0, 50) for _ in range(N)]
data = Data(label="Data", x=x, y=y, z=z)
app.data_collection.append(data)
from matplotlib import cm

scatter = app.new_data_viewer(BqplotScatterView, data=data)
layer = scatter.layers[0]
data.style.color = "blue"
scatter.state.x_att = data.id["x"]
scatter.state.y_att = data.id["y"]
layer.state.size_mode = "Linear"
layer.state.size_att = data.id["z"]
layer.state.cmap_mode = "Linear"
layer.state.fill = True
layer.state.alpha = 0.6
layer.state.size_scaling = 8
layer.state.cmap = cm.viridis


# not sure what the top level widget should be
page = scatter._layout
requirements.txt
1
2
3
4
5
6
7
8
solara
# dependencies come from another project
fast_histogram@https://py.cafe/files/maartenbreddels/glue-jupyter/fast_histogram-0.14-cp39-abi3-pyodide_2024_0_wasm32.whl
glue-jupyter@https://py.cafe/files/maartenbreddels/glue-jupyter/glue_jupyter-0.10.2.dev520+gafac49aed-py3-none-any.whl
glfw @ https://py.cafe/files/maartenbreddels/glue-jupyter/glfw-2.9.0-py3-none-any.whl
astropy-iers-data==0.2024.10.28.0.34.7 # mock
freetype-py== 2.5.0 # mock
https://py.cafe/files/maartenbreddels/glue-jupyter/vispy-0.15.2-cp312-cp312-pyodide_2024_0_wasm32.whl