Skip to content

Commit 3abd541

Browse files
committed
Updating the ipython magic for interactive matplotlib.
Interactive usage of matplotlib in Jupyter notebooks/JupyterLab requires installation of the ipympl backend. Additionally, usage of the ipython magic changed from %matplotlib notebook (used in classic notebook<7) to %matplotlib widget. https://matplotlib.org/stable/users/explain/figure/interactive.html#jupyter-notebooks-jupyterlab
1 parent d9dd685 commit 3abd541

16 files changed

+20
-17
lines changed

Python/04_Image_Display.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"source": [
2020
"import SimpleITK as sitk\n",
2121
"\n",
22-
"%matplotlib notebook\n",
22+
"%matplotlib widget\n",
2323
"import matplotlib.pyplot as plt\n",
2424
"import gui\n",
2525
"\n",

Python/05_Results_Visualization.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"metadata": {},
3333
"outputs": [],
3434
"source": [
35-
"%matplotlib notebook\n",
35+
"%matplotlib widget\n",
3636
"\n",
3737
"import numpy as np\n",
3838
"import itertools\n",

Python/21_Transforms_and_Resampling.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@
742742
"outputs": [],
743743
"source": [
744744
"# Temporarily change the matplotlib back-end to enable mouse interaction\n",
745-
"%matplotlib notebook\n",
745+
"%matplotlib widget\n",
746746
"intensity_profiles_image = sitk.ReadImage(fdata(\"training_001_ct.mha\"))\n",
747747
"point_gui = gui.PointDataAquisition(image=intensity_profiles_image);"
748748
]

Python/30_Segmentation_Region_Growing.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"outputs": [],
2424
"source": [
2525
"# To use interactive plots (mouse clicks, zooming, panning) we use the notebook back end. We want our graphs\n",
26-
"# to be embedded in the notebook, inline mode, this combination is defined by the magic \"%matplotlib notebook\".\n",
27-
"%matplotlib notebook\n",
26+
"# to be embedded in the notebook, inline mode, this combination is defined by the magic \"%matplotlib widget\".\n",
27+
"%matplotlib widget\n",
2828
"\n",
2929
"import SimpleITK as sitk\n",
3030
"\n",

Python/33_Segmentation_Thresholding_Edge_Detection.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"%run update_path_to_download_script\n",
3030
"from downloaddata import fetch_data as fdata\n",
3131
"\n",
32-
"%matplotlib notebook\n",
32+
"%matplotlib widget\n",
3333
"import gui\n",
3434
"import matplotlib.pyplot as plt\n",
3535
"\n",

Python/35_Segmentation_Shape_Analysis.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"import SimpleITK as sitk\n",
2626
"import pandas as pd\n",
2727
"\n",
28-
"%matplotlib notebook\n",
28+
"%matplotlib widget\n",
2929
"\n",
3030
"import matplotlib.pyplot as plt\n",
3131
"import gui\n",

Python/36_Microscopy_Colocalization_Distance_Analysis.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"import pandas as pd\n",
2727
"\n",
2828
"\n",
29-
"%matplotlib notebook\n",
29+
"%matplotlib widget\n",
3030
"import gui\n",
3131
"\n",
3232
"%run update_path_to_download_script\n",

Python/63_Registration_Initialization.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"%run update_path_to_download_script\n",
6363
"from downloaddata import fetch_data as fdata\n",
6464
"\n",
65-
"%matplotlib notebook\n",
65+
"%matplotlib widget\n",
6666
"import gui\n",
6767
"\n",
6868
"\n",

Python/67_Registration_Semiautomatic_Homework.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
"outputs": [],
3434
"source": [
3535
"# To use interactive plots (mouse clicks, zooming, panning) we use the notebook back end. We want our graphs\n",
36-
"# to be embedded in the notebook, inline mode, this combination is defined by the magic \"%matplotlib notebook\".\n",
37-
"%matplotlib notebook\n",
36+
"# to be embedded in the notebook, inline mode, this combination is defined by the magic \"%matplotlib widget\".\n",
37+
"%matplotlib widget\n",
3838
"\n",
3939
"import numpy as np\n",
4040
"import SimpleITK as sitk\n",

Python/68_Registration_Errors.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"import numpy as np\n",
4545
"import copy\n",
4646
"\n",
47-
"%matplotlib notebook\n",
47+
"%matplotlib widget\n",
4848
"from gui import PairedPointDataManipulation, display_errors\n",
4949
"import matplotlib.pyplot as plt\n",
5050
"from registration_utilities import registration_errors"

0 commit comments

Comments
 (0)