I want to make a demonstration for the approximation of an integral of a continuous function with piecewise constant step functions.
The resulting plot should look something like this:
I have the piece constant function, my problem is that I don't know how to plot it since the typical candidates don't seem to work:
It looks similar to a histogram, but is generated very differently.
And from what I have seen bar-charts don't align to the number line.
The plt.step()
method on the other hand does not include the bins/bars; using it I got this so far:
with this code
kwargs = dict(drawstyle = 'steps-mid')
plt.plot(times, f(times), '-')
plt.plot(times, fitted_values, **kwargs)
Is there a dedicated function, or some kwargs argument that I overlooked, that can plot what I need here?
CodePudding user response: