Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 96ff817

Browse files
committed
Switch mri_demo.py to OO interface
1 parent db3d206 commit 96ff817

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

examples/pylab_examples/mri_demo.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
import matplotlib.pyplot as plt
44
import matplotlib.cbook as cbook
5+
import matplotlib.cm as cm
56
import numpy as np
67

8+
fig, ax = plt.subplots(num="MRI_demo")
9+
710
# Data are 256x256 16 bit integers
811
dfile = cbook.get_sample_data('s1045.ima.gz')
912
im = np.fromstring(dfile.read(), np.uint16).astype(float)
1013
im.shape = (256, 256)
1114
dfile.close()
1215

13-
plt.imshow(im, cmap=plt.cm.gray)
14-
plt.axis('off')
16+
ax.imshow(im, cmap=cm.gray)
17+
ax.axis('off')
1518

1619
plt.show()

0 commit comments

Comments
 (0)