Skip to content

Instantly share code, notes, and snippets.

@tenuki
Last active March 29, 2016 04:06
Show Gist options
  • Save tenuki/1b2da67d387b33fd74b5 to your computer and use it in GitHub Desktop.
Save tenuki/1b2da67d387b33fd74b5 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib
from matplotlib import pyplot as plt
class GrafGen:
def __init__(self, max_coor, values=50):
self._max = max_coor
self.values = values
def PointGen(self):
mp = self._max*2
C = lambda x:1.0*(x-self._max)/mp
for x in xrange(self.values+1):
for y in xrange(self.values+1):
z = C(x)+(C(y)*1j)
yield z
def Show(self, filter_func):
min_x = min_y = -1 * self._max
max_x = max_y = self._max
points_x, points_y = [], []
for z in self.PointGen():
if filter_func(z):
points_x.append(z.real)
points_y.append(z.imag)
#print len(points_x)
plt.plot(points_x, points_y, "ro")
plt.axis([min_x, max_x, min_y, max_y])
plt.show()
F = lambda z: ((1+2*1j)*z).real>=0
c = GrafGen(3)
c.Show(F)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment