Streamlit Applications¶

This work is licensed under a Creative Commons Attribution 4.0 International License.
Streamlit applications provide Python-based interactive tools for exploring fractals and computing fractal dimensions. These applications are ideal for scientific exploration and analysis.
Running Streamlit Apps¶
Quick Start¶
cd apps
pip install -r requirements.txt
streamlit run mandelbrot.py
Available Applications¶
| Application | File | Description |
|---|---|---|
| Mandelbrot Explorer | mandelbrot.py |
Interactive Mandelbrot set with zoom |
| Julia Set Generator | julia.py |
Julia set visualization with parameter control |
| Branching Tree | branching_tree.py |
Self-affine branching structure |
| Pythagoras Tree | pythagoras_tree.py |
Classic Pythagoras tree fractal |
Mandelbrot Explorer¶
Interactive exploration of the Mandelbrot set with:
- Zoom controls: Click to zoom into regions of interest
- Iteration depth: Adjust maximum iterations for detail
- Color schemes: Multiple coloring algorithms
- Export: Save high-resolution images
Usage¶
streamlit run apps/mandelbrot.py
Mathematical Background¶
The Mandelbrot set consists of complex numbers \( c \) where the sequence:
remains bounded (i.e., \( |z_n| < 2 \) for all \( n \)).
Julia Set Generator¶
Generate Julia sets for any complex parameter \( c \).
Features¶
- Parameter selection: Slider controls for real and imaginary parts of \( c \)
- Connected vs disconnected: Visualize how the Julia set changes
- Escape time coloring: Multiple algorithms
- Animation: Animate through parameter space
Mathematical Background¶
For a fixed \( c \), the Julia set is the boundary of points \( z_0 \) for which:
remains bounded.
Branching Tree¶
Generate self-affine branching structures that model plant vascular networks.
Parameters¶
| Parameter | Description | Range |
|---|---|---|
| Branching angle | Angle between child branches | 0°-90° |
| Length ratio | Ratio of child to parent length | 0.5-0.9 |
| Width ratio | Ratio of child to parent width | 0.5-0.9 |
| Iterations | Number of branching levels | 1-15 |
Self-Affinity¶
When length ratio ≠ width ratio, the tree exhibits self-affine scaling:
This matches the predictions of Metabolic Scaling Theory.
Pythagoras Tree¶
The classic Pythagoras tree fractal using self-similar squares.
Features¶
- Angle control: Adjust the branching angle (default 45°)
- Depth control: Number of iterations
- Symmetric vs asymmetric: Toggle symmetric branching
- Color by depth: Visual hierarchy
Construction¶
Each iteration: 1. Draw a square on each leaf 2. Construct two smaller squares forming a right triangle 3. Repeat
With angle \( \theta \), the scaling factor is \( r = \cos\theta \).
Development Guide¶
Creating New Streamlit Apps¶
- Create a new
.pyfile inapps/:
import streamlit as st
import numpy as np
import matplotlib.pyplot as plt
st.title("My Fractal App")
# Parameters
iterations = st.slider("Iterations", 1, 100, 50)
# Computation
# ... your fractal algorithm ...
# Display
fig, ax = plt.subplots()
ax.imshow(result)
st.pyplot(fig)
- Run with
streamlit run apps/your_app.py
Dependencies¶
Key packages used:
streamlit: Web interfacenumpy: Numerical computationnumba: JIT compilation for speedmatplotlib: Static visualizationplotly: Interactive visualizationscipy: Scientific algorithmspillow: Image processing
Performance Tips¶
- Use
@st.cache_datafor expensive computations - Use
numbaJIT for numerical loops - Consider WebGL alternatives for real-time interaction
Docker Deployment¶
For production deployment:
cd docker
docker build -t streamlit-fractals .
docker run -p 8501:8501 streamlit-fractals
The Dockerfile includes all dependencies and exposes port 8501.