ereniko's picture
v0.9.0: Debian 12 Linux image with a much bigger toolset
0d56bc3 unverified
Raw History Blame Contribute Delete
478 Bytes
# Draws a chart with matplotlib and saves it as plot.png (open it in the Files view).
import math
import matplotlib.pyplot as plt
xs = [i / 10 for i in range(0, 101)]
fig, ax = plt.subplots(figsize=(7, 4), dpi=110)
ax.plot(xs, [math.sin(x) for x in xs], label="sin(x)")
ax.plot(xs, [math.cos(x) * 0.6 for x in xs], label="0.6 cos(x)")
ax.set_title("Plotted inside your browser")
ax.grid(alpha=0.3)
ax.legend()
fig.tight_layout()
fig.savefig("plot.png")
print("Wrote plot.png")