|
272 | 272 | "\n",
|
273 | 273 | "If we make sure interactive mode is off when we create the figure then the figure will only display where we want it to.\n",
|
274 | 274 | "\n",
|
275 |
| - "There is ongoing work to allow usage of `ioff` as a context manager, see the [ipympl issue](https://github.com/matplotlib/ipympl/issues/220) and the [matplotlib issue](https://github.com/matplotlib/matplotlib/issues/17013)" |
| 275 | + "To do this you can use `plt.ioff()` as a context manager." |
276 | 276 | ]
|
277 | 277 | },
|
278 | 278 | {
|
|
281 | 281 | "metadata": {},
|
282 | 282 | "outputs": [],
|
283 | 283 | "source": [
|
284 |
| - "plt.ioff()\n", |
285 |
| - "fig = plt.figure()\n", |
286 |
| - "plt.ion()\n", |
| 284 | + "with plt.ioff():\n", |
| 285 | + " fig = plt.figure()\n", |
287 | 286 | "\n",
|
288 | 287 | "ax = fig.gca()\n",
|
289 | 288 | "ax.imshow(Z)\n",
|
|
301 | 300 | "source": [
|
302 | 301 | "# Interacting with other widgets\n",
|
303 | 302 | "\n",
|
304 |
| - "## Changing a line plot with a slide" |
| 303 | + "## Changing a line plot with a slider" |
305 | 304 | ]
|
306 | 305 | },
|
307 | 306 | {
|
|
385 | 384 | "metadata": {},
|
386 | 385 | "outputs": [],
|
387 | 386 | "source": [
|
388 |
| - "plt.ioff()\n", |
389 |
| - "fig = plt.figure()\n", |
390 |
| - "plt.ion()\n", |
| 387 | + "with plt.ioff():\n", |
| 388 | + " fig = plt.figure()\n", |
391 | 389 | "im = plt.imshow(example_image_stack[0])\n",
|
392 | 390 | "\n",
|
393 | 391 | "def update(change):\n",
|
|
425 | 423 | "metadata": {},
|
426 | 424 | "outputs": [],
|
427 | 425 | "source": [
|
428 |
| - "plt.ioff()\n", |
429 |
| - "fig = plt.figure()\n", |
430 |
| - "plt.ion()\n", |
| 426 | + "with plt.ioff():\n", |
| 427 | + " fig = plt.figure()\n", |
431 | 428 | "im = plt.imshow(example_image_stack[0])\n",
|
432 | 429 | "\n",
|
433 | 430 | "out = widgets.Output()\n",
|
|
448 | 445 | ],
|
449 | 446 | "metadata": {
|
450 | 447 | "kernelspec": {
|
451 |
| - "display_name": "Python 3", |
| 448 | + "display_name": "Python 3 (ipykernel)", |
452 | 449 | "language": "python",
|
453 | 450 | "name": "python3"
|
454 | 451 | },
|
|
462 | 459 | "name": "python",
|
463 | 460 | "nbconvert_exporter": "python",
|
464 | 461 | "pygments_lexer": "ipython3",
|
465 |
| - "version": "3.8.6" |
| 462 | + "version": "3.11.0" |
466 | 463 | },
|
467 | 464 | "widgets": {
|
468 | 465 | "application/vnd.jupyter.widget-state+json": {
|
|
0 commit comments