0

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:

enter image description here

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?

1 Answer 1

1

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")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.