Skip to content

Instantly share code, notes, and snippets.

@astrofrog
Created March 26, 2020 12:03
Show Gist options
  • Save astrofrog/45eab0b3b978b7fd4c35a7520e97220a to your computer and use it in GitHub Desktop.
Save astrofrog/45eab0b3b978b7fd4c35a7520e97220a to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from bqplot import Figure, LinearScale, Axis, ColorScale\n",
"from bqplot_image_gl import ImageGL, __path__\n",
"from bqplot_image_gl.interacts import BrushEllipseSelector\n",
"print(__path__)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"scale_x = LinearScale(min=0, max=1)\n",
"scale_y = LinearScale(min=0, max=1)\n",
"scales = {'x': scale_x,\n",
" 'y': scale_y}\n",
"axis_x = Axis(scale=scale_x, label='x')\n",
"axis_y = Axis(scale=scale_y, label='y', orientation='vertical')\n",
"\n",
"figure = Figure(scales=scales, axes=[axis_x, axis_y])\n",
"\n",
"scales_image = {'x': scale_x,\n",
" 'y': scale_y,\n",
" 'image': ColorScale(min=0, max=1)}\n",
"\n",
"image = ImageGL(image=np.random.random((10, 10)), scales=scales_image)\n",
"\n",
"figure.marks = (image,)\n",
"\n",
"figure.interaction = BrushEllipseSelector(x_scale=figure.axes[0].scale, y_scale=figure.axes[1].scale)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"figure"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment