I am trying to create subplots with matshow. However, my code seems to be displaying only the last matshow image and two blank plots in separate figures. Can someone tell me what I am doing wrong?

from matplotlib.pylab import *

def SliceMat(N, i):

slice = zeros( (N, N) )

for j in range(N):

for k in range(N):

val = 0 # black

if(i>j>k and ((i+j+k)%3==1)):

val=1 # red

if(j>k>i and ((i+j+k)%3==2)):

val=2 # yellow

if (k>i>j and ((i+j+k)%3==0)):

val=3 # white

slice[j,k] = val

return slice

N=8

subplot(121)

slice = SliceMat(N, 2)

matshow(slice, cmap=cm.hot, origin='lower')

subplot(122)

slice = SliceMat(N, 5)

matshow(slice, cmap=cm.hot, origin='lower')

show()

## ···

_________________________________________________________________

Connect with your friends who use Yahoo! Messenger with Voice. Click! http://www.msnspecials.in/wlmyahoo/index.asp