Skip to content
Competition - Phyllotaxis
import numpy as np
import matplotlib.pyplot as plt
# Increase the number of points for a more intricate design
points = 10000
# Define multiple angles for a variety of spirals and leaf patterns
angles_flowers = [np.pi * (2 - np.sqrt(3)), np.pi * (3 - np.sqrt(5))]
angles_leaves = [np.pi * (1 - np.sqrt(2)), np.pi * (2 - np.sqrt(4))]
# Initialize plot
plt.figure(figsize=(14, 14))
# Plot flowers
for angle in angles_flowers:
t = np.arange(1, points // 2 + 1) * angle
r = np.sqrt(t)
x = r * np.sin(t)
y = r * np.cos(t)
colors_flowers = plt.cm.spring(np.linspace(0, 1, points // 2))
sizes_flowers = np.abs(np.sin(t) * 50) + np.random.randn(points // 2) * 2
plt.scatter(x, y, c=colors_flowers, s=sizes_flowers, alpha=0.6, edgecolor='none')
# Plot leaves
for angle in angles_leaves:
t = np.arange(1, points // 2 + 1) * angle
r = np.sqrt(t)
x = r * np.sin(t)
y = r * np.cos(t)
# Introduce a slight randomness in rotation for a more dynamic look
rotation_angle = np.random.rand() * 2 * np.pi
x_rotated = x * np.cos(rotation_angle) - y * np.sin(rotation_angle)
y_rotated = x * np.sin(rotation_angle) + y * np.cos(rotation_angle)
colors_leaves = plt.cm.summer(np.linspace(0, 1, points // 2))
sizes_leaves = np.abs(np.sin(t) * 30) + np.random.randn(points // 2) * 1.5
plt.scatter(x_rotated, y_rotated, c=colors_leaves, s=sizes_leaves, alpha=0.4, edgecolor='none')
plt.axis('off') # Hide the axes for a cleaner look
plt.show()