File size: 478 Bytes
0d56bc3
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 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")