Skip to content

Commit 05b9e33

Browse files
authored
Merge pull request #111 from jupyter-widgets/fix_bqplot_example
Fix bqplot example
2 parents 6fd9651 + b70d821 commit 05b9e33

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

notebooks/07.03-bqplot.ipynb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@
343343
"metadata": {},
344344
"outputs": [],
345345
"source": [
346-
"from bqplot import *\n",
346+
"from bqplot import (LinearScale, Scatter, Label, Axis, Figure, Lines)\n",
347+
"import numpy as np\n",
347348
"\n",
348349
"size = 100\n",
349350
"np.random.seed(0)\n",
@@ -359,13 +360,13 @@
359360
"scat = Scatter(x=x_data[:10], y=y_data[:10], scales={'x': sc_x, 'y': sc_y}, default_colors=['blue'],\n",
360361
" enable_move=True)\n",
361362
"lin = Lines(scales={'x': sc_x, 'y': sc_y}, stroke_width=4, line_style='dashed', colors=['orange'])\n",
362-
"m = Label(value='Mean is %s'%np.mean(scat.y))\n",
363+
"m = Label(x=[0.05], y=[0.9], text=[\"\"], colors=[\"black\"])\n",
363364
"\n",
364365
"def update_line(change):\n",
365366
" with lin.hold_sync():\n",
366367
" lin.x = [np.min(scat.x), np.max(scat.x)]\n",
367368
" lin.y = [np.mean(scat.y), np.mean(scat.y)]\n",
368-
" m.value='Mean is %s'%np.mean(scat.y)\n",
369+
" m.text=['Mean is %s'%np.mean(scat.y)]\n",
369370
" \n",
370371
"\n",
371372
"update_line(None)\n",
@@ -377,15 +378,15 @@
377378
"ax_x = Axis(scale=sc_x)\n",
378379
"ax_y = Axis(scale=sc_y, tick_format='0.2f', orientation='vertical')\n",
379380
"\n",
380-
"fig = Figure(marks=[scat, lin], axes=[ax_x, ax_y])\n",
381+
"fig = Figure(marks=[scat, lin, m], axes=[ax_x, ax_y])\n",
381382
"\n",
382383
"## In this case on drag, the line updates as you move the points.\n",
383384
"with scat.hold_sync():\n",
384385
" scat.enable_move = True\n",
385386
" scat.update_on_move = True\n",
386387
" scat.enable_add = False\n",
387388
"\n",
388-
"display(m, fig)"
389+
"display(fig)"
389390
]
390391
},
391392
{

0 commit comments

Comments
 (0)