import os,sys
import webbrowser
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.cm as cm
import matplotlib.pylab as plt
from matplotlib import ticker

plt.rcParams['font.family'] = 'monospace'
fig = plt.figure()
rect = fig.add_subplot(111, aspect='equal')
data0 = np.loadtxt('data0.dat', delimiter=',')
data1 = np.loadtxt('data1.dat', delimiter=',')
dense = np.loadtxt('dense.dat', delimiter=',')
ID = sys.argv[1]
X = np.arange(-2.0, 2.05, 0.05)
Y = np.arange(-2.0, 2.05, 0.05)
Xm, Ym = np.meshgrid(X, Y)
vmin, vmax = dense.min(), dense.max()
if vmin * vmax < 0:
	vmin = -abs(max(-vmin, vmax))
	vmax = +abs(max(-vmin, vmax))
cr = rect.imshow(dense.reshape((len(Y), len(X))), extent=(X[0], X[-1], Y[0], Y[-1]), vmin=vmin, vmax=vmax, cmap=cm.coolwarm, origin='lower')
plt.contour(Xm, Ym, dense, levels=[-1, 1], cmap=cm.bwr, linestyles='dashed', linewidths=[2,2])
plt.contour(Xm, Ym, dense, levels=[0], colors='black', linestyles='dashed', linewidths=[2])
cb = plt.colorbar(cr, format='%+.1e')
cb.solids.set_edgecolor('face')
cb.set_ticks(ticker.LinearLocator(6))
cb.ax.tick_params(labelsize=12)
rect.scatter(data0[:,0], data0[:,1], marker='v', facecolor='red',  edgecolor='black', s=30, lw=1)
rect.scatter(data1[:,0], data1[:,1], marker='^', facecolor='blue', edgecolor='black', s=30, lw=1)
plt.xlim(X[0], X[-1])
plt.ylim(Y[0], Y[-1])
plt.xlabel("")
plt.ylabel("")
plt.grid(ls='dotted')
plt.savefig('{}.svg'.format(ID), bbox_inches='tight', pad_inches=0.1)
plt.savefig('{}.eps'.format(ID), bbox_inches='tight', pad_inches=0.1)
os.remove('dense.dat')
os.remove('data0.dat')
os.remove('data1.dat')
webbrowser.open('file://{}'.format(os.path.realpath('{}.svg'.format(sys.argv[1]))))

[((5, 0, 5, 21), 'matplotlib.use', 'matplotlib.use', ({(5, 15, 5, 20): '"""Agg"""'}, {}), "('Agg')", False, 'import matplotlib\n'), ((11, 6, 11, 18), 'matplotlib.pylab.figure', 'plt.figure', ({}, {}), '()', True, 'import matplotlib.pylab as plt\n'), ((13, 8, 13, 46), 'numpy.loadtxt', 'np.loadtxt', (), '', True, 'import numpy as np\n'), ((14, 8, 14, 46), 'numpy.loadtxt', 'np.loadtxt', (), '', True, 'import numpy as np\n'), ((15, 8, 15, 46), 'numpy.loadtxt', 'np.loadtxt', (), '', True, 'import numpy as np\n'), ((17, 4, 17, 31), 'numpy.arange', 'np.arange', ({(17, 14, 17, 18): '-2.0', (17, 20, 17, 24): '2.05', (17, 26, 17, 30): '0.05'}, {}), '(-2.0, 2.05, 0.05)', True, 'import numpy as np\n'), ((18, 4, 18, 31), 'numpy.arange', 'np.arange', ({(18, 14, 18, 18): '-2.0', (18, 20, 18, 24): '2.05', (18, 26, 18, 30): '0.05'}, {}), '(-2.0, 2.05, 0.05)', True, 'import numpy as np\n'), ((19, 9, 19, 26), 'numpy.meshgrid', 'np.meshgrid', ({(19, 21, 19, 22): 'X', (19, 24, 19, 25): 'Y'}, {}), '(X, Y)', True, 'import numpy as np\n'), ((25, 0, 25, 94), 'matplotlib.pylab.contour', 'plt.contour', (), '', True, 'import matplotlib.pylab as plt\n'), ((26, 0, 26, 91), 'matplotlib.pylab.contour', 'plt.contour', (), '', True, 'import matplotlib.pylab as plt\n'), ((27, 5, 27, 37), 'matplotlib.pylab.colorbar', 'plt.colorbar', (), '', True, 'import matplotlib.pylab as plt\n'), ((33, 0, 33, 21), 'matplotlib.pylab.xlim', 'plt.xlim', ({(33, 9, 33, 13): 'X[0]', (33, 15, 33, 20): 'X[-1]'}, {}), '(X[0], X[-1])', True, 'import matplotlib.pylab as plt\n'), ((34, 0, 34, 21), 'matplotlib.pylab.ylim', 'plt.ylim', ({(34, 9, 34, 13): 'Y[0]', (34, 15, 34, 20): 'Y[-1]'}, {}), '(Y[0], Y[-1])', True, 'import matplotlib.pylab as plt\n'), ((35, 0, 35, 14), 'matplotlib.pylab.xlabel', 'plt.xlabel', ({(35, 11, 35, 13): '""""""'}, {}), "('')", True, 'import matplotlib.pylab as plt\n'), ((36, 0, 36, 14), 'matplotlib.pylab.ylabel', 'plt.ylabel', ({(36, 11, 36, 13): '""""""'}, {}), "('')", True, 'import matplotlib.pylab as plt\n'), ((37, 0, 37, 21), 'matplotlib.pylab.grid', 'plt.grid', (), '', True, 'import matplotlib.pylab as plt\n'), ((40, 0, 40, 22), 'os.remove', 'os.remove', ({(40, 10, 40, 21): '"""dense.dat"""'}, {}), "('dense.dat')", False, 'import os, sys\n'), ((41, 0, 41, 22), 'os.remove', 'os.remove', ({(41, 10, 41, 21): '"""data0.dat"""'}, {}), "('data0.dat')", False, 'import os, sys\n'), ((42, 0, 42, 22), 'os.remove', 'os.remove', ({(42, 10, 42, 21): '"""data1.dat"""'}, {}), "('data1.dat')", False, 'import os, sys\n'), ((29, 13, 29, 36), 'matplotlib.ticker.LinearLocator', 'ticker.LinearLocator', ({(29, 34, 29, 35): '(6)'}, {}), '(6)', False, 'from matplotlib import ticker\n')]