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