Skip to content

Instantly share code, notes, and snippets.

@TurkishChaot
TurkishChaot / chaos.py
Created May 3, 2012 15:52
pyChaos#15 - Chaos plot
f4 = lambda x: 3.8 * (x - x**2)
sequence = SequenceForIteratedFunction(f4, 0.2, 200)
p = Plotter(sequence)
@TurkishChaot
TurkishChaot / fourlibrium.py
Created May 3, 2012 15:52
pyChaos#14 - Fourlibrium plot
f3 = lambda x: 3.5 * (x - x**2)
sequence = SequenceForIteratedFunction(f3, 0.2, 200)
p = Plotter(sequence)
@TurkishChaot
TurkishChaot / doublibrium.py
Created May 3, 2012 15:51
pyChaos#12 - Doublibrium plot
f2 = lambda x: 3.2 * (x - x**2)
sequence = SequenceForIteratedFunction(f2, 0.2, 200)
p = Plotter(sequence)
@TurkishChaot
TurkishChaot / equilibrium.py
Created May 3, 2012 15:50
pyChaous#12 - Equilibrium plot
sequence = SequenceForIteratedFunction(f1, 0.2, 200)
p = Plotter(sequence)
@TurkishChaot
TurkishChaot / parabolla.py
Created May 3, 2012 15:49
pyChaos#11 - Parabolla plot
f1 = lambda x: 2.2 * (x - x**2)
funcSequence = SequenceForFunction(f1, 0.0, 1.0, 200)
pfunc = Plotter(funcSequence)
@TurkishChaot
TurkishChaot / init.py
Created May 3, 2012 15:48
pyChaos#10 - Plotter.init
class Plotter:
def __init__(self, sequence, width = 1000, height = 400, boundariesSizeQuotient = 0.06):
self.values = sequence
self.valuesCount = len(self.values)
self.sizeQuotient = boundariesSizeQuotient
self.DeterminePlotBoundaries(width, height)
self.CreateCanvas(width, height)
self.DrawGrid()
@TurkishChaot
TurkishChaot / createcanvas.py
Created May 3, 2012 15:47
pyChaos#9 - Plotter.CreateCanvas
def CreateCanvas(self, width, height):
self.root = Tk()
self.canvas = Canvas(self.root, width = width, height = height)
@TurkishChaot
TurkishChaot / plotboundaries.py
Created May 3, 2012 15:46
pyChaos#8 - Plotter.DeterminePlotBoundaries
def DeterminePlotBoundaries(self, width, height):
self.upper = height * self.sizeQuotient
self.lower = height * (1.0 - self.sizeQuotient)
self.left = width * self.sizeQuotient
self.right = width * (1.0 - self.sizeQuotient)
@TurkishChaot
TurkishChaot / transform.py
Created May 3, 2012 15:45
pyChaos#7 - Plotter.Transform
def Transform(self, y):
return self.lower - y*(self.lower - self.upper)
@TurkishChaot
TurkishChaot / drawdata.py
Created May 3, 2012 15:44
pyChaos#6 - Plotter.DrawData
def DrawData(self):
dataColor = "black"
xStep = self.XStep()
for i in range(1, self.valuesCount):
x1 = self.left + xStep*(i-1)
y1 = self.Transform(self.values[i-1])
x2 = self.left + xStep*i
y2 = self.Transform(self.values[i])
self.canvas.create_line(x1, y1, x2, y2, fill = dataColor)