Skip to content

Instantly share code, notes, and snippets.

@bhushanbrb
Created September 22, 2018 19:33
Show Gist options
  • Save bhushanbrb/018ff08da81ffa2782c3ca2df7115f48 to your computer and use it in GitHub Desktop.
Save bhushanbrb/018ff08da81ffa2782c3ca2df7115f48 to your computer and use it in GitHub Desktop.
DecisionBoundryColor
#%matplotlib notebook
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import colors as c
import time
fig = plt.figure()
ax = fig.gca()
resolution=200
xs = np.linspace(-3., 3., resolution)
ys = np.linspace(-3., 3., resolution)
xx, yy = np.meshgrid(xs, ys)
zz=2*xx+4*yy-5
zz[zz<0]=-1
zz[zz>0]=+1
cMap = c.ListedColormap(['r','g'])
quad = ax.pcolormesh(xs, ys, zz,cmap=cMap)
positive = np.array([[2, 2], [1, 2]])
negative = np.array([[0, 0], [-1, -2]])
plt.plot(positive[:, 0], positive[:,1], 'ro', markersize=10)
plt.plot(negative[:, 0], negative[:,1], 'yo', markersize=10)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment