matplotlib python, построение графика
Никак не пойму как построить график, зависимости погрешности от количества разбиений(прямоугольников), для вычисления площади криволинейной трапеции по методу прямоугольников. В данном случае график x**3
# importing module
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 2, 100) # Sample data.
plt.figure(figsize=(8, 4), layout='constrained')
plt.plot(x, x**3, label='cubic')
# sqr
Length = 0
for n in range(0, 20, 1):
n = n/10
x1 = [n, n]
y1 = n**3
y0 = [0, y1]
plt.plot(x1, y0)
x2 = [n, n + 0.1]
y2 = n**3
y = [y2, y2]
plt.plot(x2, y)
Length = Length + y1
S = 0.1*Length
print(S)
# depicting the visualization
plt.xlabel('x label')
plt.ylabel('y label')
# displaying the title
plt.title("Cubic graph")
plt.legend()
plt.show()