import numpy as np
import matplotlib.pyplot as plt
from komorebi_browser import show_matplotlib, export_file

x = np.linspace(-2, 2, 81)
y = x**2
fig, ax = plt.subplots(figsize=(7, 4))
ax.plot(x, y, color="#18563d", label="y = x²")
ax.set(xlabel="x", ylabel="y", title="A parabola")
ax.grid(True, alpha=0.3)
ax.legend()
show_matplotlib(fig, description="A parabola with its minimum at the origin. Values rise to four at x = minus two and two.")
export_file("parabola.csv", "x,y\n" + "".join(f"{a},{b}\n" for a,b in zip(x,y)))
print("Created a Matplotlib figure and parabola.csv.")
