8000 added 2nd image demo · matplotlib/matplotlib@85d9a95 · GitHub
[go: up one dir, main page]

Skip to content

Commit 85d9a95

Browse files
committed
added 2nd image demo
svn path=/trunk/matplotlib/; revision=181
1 parent d4ae2c5 commit 85d9a95

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

examples/image_demo2.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from matplotlib.matlab import *
2+
3+
w, h = 512, 512
4+
s = file('data/ct.raw', 'rb').read()
5+
A = fromstring(s, typecode=UInt16).astype(Float)
6+
A *= 1.0/max(A)
7+
A.shape = w, h
8+
9+
im = imshow(A)
10+
im.set_aspect('free')
11+
12+
# plot some data with the image; currently broken with aspect preserve
13+
gca().set_image_extent(0, 25, 0, 25)
14+
markers = [(15.9, 14.5), (16.8, 15)]
15+
x,y = zip(*markers)
16+
plot(x, y, 'o')
17+
#axis([0,25,0,25])
18+
19+
20+
21+
#axis('off')
22+
title('CT density')
23+
24+
if 0:
25+
x = sum(A,0)
26+
subplot(212)
27+
bar(arange(w), x)
28+
set(gca(), 'xlim', [0,h-1])
29+
ylabel('density')
30+
set(gca(), 'xticklabels', [])
31+
show()
32+

0 commit comments

Comments
 (0)
0