Last active
August 29, 2015 14:14
-
-
Save bast/0ab641b9f0406b2f2f44 to your computer and use it in GitHub Desktop.
Heatmap with PyLab.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2015 Radovan Bast | |
# Licensed under the MIT license - http://opensource.org/licenses/MIT | |
import sys | |
import pylab as pl | |
file_name = sys.argv[1] | |
with open(file_name, 'r') as f: | |
lines = f.readlines() | |
mat_dim = 0 | |
for line in lines: | |
if 'raboof' in line: | |
n = int(line.split()[1]) | |
if n > mat_dim: mat_dim = n | |
data = pl.zeros([mat_dim, mat_dim]) | |
for line in lines: | |
if 'raboof' in line: | |
_, i, j, f = line.split() | |
data[int(i)-1][int(j)-1] = float(f) | |
pl.pcolor(data) | |
pl.colorbar() | |
pl.savefig("%s.png" % file_name, dpi=72) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment