A Python project that generates the Barnsley Fern fractal using an Iterated Function System (IFS). The repository contains two different implementations that produce the same fractal using different visualization methods.
- Generates the Barnsley Fern fractal
- Uses probabilistic affine transformations
- Two visualization approaches
- Demonstrates fractal geometry and chaos theory concepts
- Built with Python and NumPy
File: Barnsley (turtle).py
Draws the fractal point-by-point using Python's built-in Turtle Graphics library.
Advantages:
- Easy to understand
- Visualizes the drawing process in real time
- Suitable for learning fractal generation
File: Barnsley (matplotlib).py
Generates points and plots them using Matplotlib.
Advantages:
- Faster rendering
- Handles larger numbers of points efficiently
- Produces cleaner visualizations
Install the required packages:
pip install numpy matplotlibThe Turtle version only requires NumPy because Turtle is included with Python.
python Barnsley (turtle).pypython Barnsley (matplotlib).pyThe program generates the famous Barnsley Fern fractal, a mathematical structure that resembles a natural fern leaf.
The Barnsley fern is generated by repeatedly applying one of four affine transformations.
At each iteration:
- A transformation is selected according to a probability distribution.
- New coordinates are calculated.
- The resulting point is plotted.
- Repeating this process thousands of times creates the fern shape.
- Python 3
- NumPy
- Turtle Graphics
- Matplotlib
This project demonstrates:
- Fractal generation
- Iterated Function Systems (IFS)
- Randomized algorithms
- Data visualization
- Mathematical programming
- Interactive GUI
- Adjustable probabilities
- Animation controls
- Multiple fractal types
- High-resolution image export
This project is licensed under the MIT License.
Mohammad Reza Bakhshandeh
Electrical Engineering (Electronics) Graduate
Interested in Python Development, Computer Vision, Machine Learning, and Artificial Intelligence.

