File: matshow.py

package info (click to toggle)
matplotlib 0.98.1-1%2Blenny4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 18,624 kB
  • ctags: 22,599
  • sloc: python: 76,915; cpp: 63,459; ansic: 5,353; makefile: 111; sh: 12
file content (22 lines) | stat: -rwxr-xr-x 543 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
"""Simple matshow() example."""

from matplotlib.pylab import *

def samplemat(dims):
    """Make a matrix with all zeros and increasing elements on the diagonal"""
    aa = zeros(dims)
    for i in range(min(dims)):
        aa[i,i] = i
    return aa

# Make a few matrices of strange sizes
dimlist = [(12,12),(128,64),(64,512),(1024,128)]

for d in dimlist:
    matshow(samplemat(d))

# Display a random matrix with a specified figure number and a grayscale colormap
matshow(rand(64,64),fignum=100,cmap=cm.gray)

show()