Skip to content

Instantly share code, notes, and snippets.

@tfmoraes
Created Oct 14, 2012
Embed
What would you like to do?
plotting an arrays as image
import pylab
a = [[1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 1, 1, 2],
[1, 1, 2, 2, 2, 1, 2, 3, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 1, 2, 3],
[2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 2, 2, 3, 1],
[2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1],
[1, 1, 2, 2, 1, 2, 2, 1, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2],
[1, 1, 1, 1, 3, 1, 2, 3, 1, 2, 4, 1, 1, 2, 1, 2, 1, 2, 2, 2, 2],
[1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 3, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 5, 5, 5],
[1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 2, 5, 5, 5, 2, 2, 1, 2, 1, 1, 1],
[4, 4, 1, 6, 6, 6, 6, 6, 6, 6, 0, 5, 5, 5, 5, 5, 5, 5, 3, 2, 2],
[3, 3, 3, 4, 3, 4, 4, 6, 6, 6, 4, 4, 3, 4, 3, 3, 3, 3, 3, 3, 3],
[6, 6, 6, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3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