Skip to content

Instantly share code, notes, and snippets.

@tfmoraes
Created October 14, 2012 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfmoraes/3886814 to your computer and use it in GitHub Desktop.
Save tfmoraes/3886814 to your computer and use it in GitHub Desktop.
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, 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