Skip to content

Commit df3340c

Browse files
committed
Add missing calls to plt.show.
The ipympl backend doesn't display figures automatically, add the call to plt.show to force display.
1 parent 2f24fab commit df3340c

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

Python/04_Image_Display.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@
259259
" \"grey colormap,\\n scaling based on volumetric min and max values\", fontsize=10\n",
260260
")\n",
261261
"plt.imshow(npa_zslice, cmap=plt.cm.Greys_r, vmin=npa.min(), vmax=npa.max())\n",
262-
"plt.axis(\"off\");"
262+
"plt.axis(\"off\")\n",
263+
"plt.show()"
263264
]
264265
},
265266
{
@@ -321,6 +322,7 @@
321322
"plt.figure(figsize=(10, 2))\n",
322323
"plt.imshow(sitk.GetArrayViewFromImage(sitk_isotropic_xslice), cmap=plt.cm.Greys_r)\n",
323324
"plt.axis(\"off\")\n",
325+
"plt.show()\n",
324326
"print(f\"Image spacing: {sitk_isotropic_xslice.GetSpacing()}\")"
325327
]
326328
},

Python/69_x-ray-panorama.ipynb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@
136136
"source": [
137137
"intensity_profile_image = knee_image\n",
138138
"fig = plt.figure()\n",
139-
"plt.hist(sitk.GetArrayViewFromImage(intensity_profile_image).flatten(), bins=100);"
139+
"plt.hist(sitk.GetArrayViewFromImage(intensity_profile_image).flatten(), bins=100)\n",
140+
"plt.show()"
140141
]
141142
},
142143
{
@@ -180,7 +181,8 @@
180181
"axes[1].plot(intensities.mean(axis=1), range(intensities.shape[0]))\n",
181182
"axes[1].get_yaxis().set_visible(False)\n",
182183
"axes[1].tick_params(axis=\"x\", rotation=-90)\n",
183-
"plt.box(on=None)"
184+
"plt.box(on=None)\n",
185+
"plt.show()"
184186
]
185187
},
186188
{

Python/gui.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def __init__(
9999
vmax=self.moving_max_intensity,
100100
)
101101
self.update_display()
102+
plt.show()
102103

103104
def create_ui(self):
104105
# Create the active UI components. Height and width are specified in 'em' units. This is
@@ -414,6 +415,7 @@ def __init__(self, image, window_level=None, figure_size=(10, 8)):
414415
vmax=self.max_intensity,
415416
)
416417
self.update_display()
418+
plt.show()
417419

418420
def create_ui(self):
419421
# Create the active UI components. Height and width are specified in 'em' units. This is
@@ -624,6 +626,7 @@ def multi_image_display2D(
624626
ax.set_title(title)
625627
ax.set_axis_off()
626628
fig.tight_layout()
629+
plt.show()
627630
return (fig, axes)
628631

629632

@@ -693,6 +696,7 @@ def __init__(
693696
)
694697
self.update_display()
695698
plt.tight_layout()
699+
plt.show()
696700

697701
def create_ui(self, shared_slider, wl_range, wl_init):
698702
# Create the active UI components. Height and width are specified in 'em' units. This is
@@ -877,6 +881,7 @@ def __init__(self, image, window_level=None, figure_size=(10, 8)):
877881
vmax=self.max_intensity,
878882
)
879883
self.update_display()
884+
plt.show()
880885

881886
def create_ui(self):
882887
# Create the active UI components. Height and width are specified in 'em' units. This is
@@ -1176,6 +1181,7 @@ def __init__(
11761181
self.fig.canvas.mpl_connect("button_release_event", self.on_release)
11771182

11781183
self.update_display()
1184+
plt.show()
11791185

11801186
def create_ui(self):
11811187
# Create the active UI components. Height and width are specified in 'em' units. This is

0 commit comments

Comments
 (0)