File size: 1,123 Bytes
d323f57 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import numpy as np
import matplotlib.pyplot as plt
# ── Parameters ──────────────────────────────────────────────────────────────
seed = 3905
n_petals = 5 # k in r = A|cos(k·θ/2)|
amplitude = 1.350061
n_points = 1000
# ── Data ────────────────────────────────────────────────────────────────────
theta = np.linspace(0.0, 2.0 * np.pi, n_points)
r = amplitude * np.abs(np.cos(n_petals * theta / 2.0))
# ── Plot ─────────────────────────────────────────────────────────────────────
fig, ax = plt.subplots(subplot_kw={"projection": "polar"}, figsize=(5, 5))
ax.plot(theta, r, linewidth=1.5)
ax.set_title(
f"Rose Curve (k={n_petals}, A={amplitude:.2f})", pad=15
)
fig.tight_layout()
plt.show()
|