{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "06ac2448-da47-4939-a22a-e4b556fba103", "metadata": {}, "outputs": [], "source": [ "from bqplot import *\n", "from bqplot.interacts import *\n", "\n", "# Create Scatter\n", "sc_x = LinearScale()\n", "sc_y = LinearScale()\n", "\n", "scatt = Scatter(\n", " x=list(range(10)), \n", " y=[20, 3, 23, 5, 6, 12, 23, 14, 20, 3],\n", " scales={'x': sc_x, 'y': sc_y},\n", " selected_style={\"opacity\": \"1\"},\n", " unselected_style={\"opacity\": \"0.2\"}\n", ")\n", "\n", "sel = IndexSelector(\n", " marks=[scatt], \n", " scale=sc_x,\n", " selected=3\n", ")\n", "\n", "ax_x = Axis(scale=sc_x)\n", "ax_y = Axis(scale=sc_y, orientation='vertical')\n", "\n", "fig = Figure(\n", " marks=[scatt], \n", " axes=[ax_x, ax_y],\n", " interaction=sel\n", ")\n", "fig" ] }, { "cell_type": "code", "execution_count": null, "id": "a0600d9f-2256-4610-a14e-471c255d4924", "metadata": {}, "outputs": [], "source": [ "sel.selected = 5" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.10.0" } }, "nbformat": 4, "nbformat_minor": 5 }