From aaec22c87c2edfdc96e6e000d8396ae74b88336c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Wobst?= Date: Mon, 2 Feb 2004 10:57:32 +0000 Subject: [PATCH] mandel example contributed by Stephen Phillips git-svn-id: https://pyx.svn.sourceforge.net/svnroot/pyx/trunk/pyx@1314 069f4177-920e-0410-937b-c2a4a81bcd90 --- CHANGES | 6 +++++- examples/graphs/mandel.py | 41 +++++++++++++++++++++++++++++++++++++++++ www/pt2html.py | 1 + 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 examples/graphs/mandel.py diff --git a/CHANGES b/CHANGES index 2c354916..cd40e11f 100644 --- a/CHANGES +++ b/CHANGES @@ -26,7 +26,9 @@ TODO: - make dash length available - text module: - SlantFont & Co support - - keep an eye on PEP 324 (popen 5): it could make the texrunner stuff much easier + - keep an eye on PEP 324 (popen 5): it could make the texrunner much easier + - unit and text module: + - introduce xscale for scaling the TeX output - mathtree module: - consider rewrite using the python compiler module - bbox module: @@ -62,6 +64,8 @@ TODO: - zero line feature removed (TODO: documentation) - text module: - default handling of texmessages as in the new attribute scheme + - examples: + - mandel.py (contributed by Stephen Phillips) 0.5.1 (2004/01/22): - distribution: diff --git a/examples/graphs/mandel.py b/examples/graphs/mandel.py new file mode 100644 index 00000000..04cea472 --- /dev/null +++ b/examples/graphs/mandel.py @@ -0,0 +1,41 @@ +# contributed by Stephen Phillips + +from pyx import * + +# Mandelbrot parameters +re_min = -2 +re_max = 0.5 +im_min = -1.25 +im_max = 1.25 +gridx = 100 +gridy = 100 +max_iter = 10 + +# Set-up +re_step = (re_max - re_min) / gridx +im_step = (im_max - im_min) / gridy +d = [] + +# Compute fractal +for re_index in range(gridx): + re = re_min + re_step * (re_index + 0.5) + for im_index in range(gridy): + im = im_min + im_step * (im_index + 0.5) + c = complex(re, im) + n = 0 + z = complex(0, 0) + while n < max_iter and abs(z) < 2: + z = (z * z) + c + n += 1 + d.append([re - 0.5 * re_step, re + 0.5 * re_step, + im - 0.5 * im_step, im + 0.5 * im_step, + float(n)/max_iter]) + +# Plot graph +g = graph.graphxy(height=8, width=8, + x=graph.linaxis(min=re_min, max=re_max, title=r'$\Re(c)$'), + y=graph.linaxis(min=im_min, max=im_max, title=r'$\Im(c)$')) +g.plot(graph.data(data.data(d), xmin=0, xmax=1, ymin=2, ymax=3, color=4), + graph.rect(color.palette.Rainbow)) +g.dodata() # plot data first, then axes +g.writetofile('mandel.eps') diff --git a/www/pt2html.py b/www/pt2html.py index ca3bc47a..becdc358 100755 --- a/www/pt2html.py +++ b/www/pt2html.py @@ -55,6 +55,7 @@ examples = [example("hello"), example("graphs/change"), example("graphs/bar"), example("graphs/arrows"), + example("graphs/mandel"), example("graphs/integral"), example("graphs/partialfill"), example("graphs/washboard"), -- 2.11.4.GIT