Reputation: 2065
I have a set of points like this:
x_axis = np.arange(0, 100)
and
y_axis = np.zeros(100)
y_axis[17 : 23] = 1.
Now, I am plotting this data with the following code:
plt.figure(figsize=(50,1))
plt.fill_between(x_axis, 0, y_axis, color='blue', alpha=.25)
But I am getting the following image:
As the fill_between
expects corner of a polygon this is expected. I want to plot a filled square between 17
to 23
. How do I achieve this instead of a trapezium?
Upvotes: 0
Views: 81
Reputation: 51
Is step argument helping you ? You can set it to "pre" or "post".
plt.fill_between(x_axis, 0, y_axis, color='blue', alpha=.25, step="pre")
Upvotes: 1