Skip to content

Instantly share code, notes, and snippets.

@nickponline

nickponline/viz.py Secret

Last active Sep 20, 2016
Embed
What would you like to do?
import matplotlib.pyplot as pylab
global SHOW
SHOW = True
def figure(force=False):
global SHOW
if force: SHOW = True
if not SHOW: return
pylab.figure()
def plot_points(points, color='ko'):
global SHOW
if not SHOW: return
x, y = zip(*points)
pylab.plot(x, y, color, markersize=5, markeredgewidth=0.0, fillstyle='full')
def plot_line(xi, yi, xj, yj):
global SHOW
if not SHOW: return
#pylab.plot([xi, xj], [yi, yj], 'ko', markersize=5, markeredgewidth=0.0, fillstyle='full')
pylab.plot([xi, xj], [yi, yj], 'k')
def plot_circle(x, y, r):
global SHOW
if not SHOW: return
circle = pylab.Circle((x, y), r, color='#2ecc71', alpha=0.1)
pylab.gca().add_artist(circle)
def show(range):
global SHOW
if not SHOW: return
pylab.xlim([-2*range, 2*range])
pylab.ylim([-2*range, 2*range])
pylab.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment