0

How to fill the following region:

(x < 100) & (y > 10)

import numpy as np, matplotlib.pyplot as plt

x = np.arange(0,255,0.1)
y = np.arange(0,255,0.1)

plt.plot(x,y)
plt.fill_between(range(0,100), range(10,100),color='r',alpha=.3)
plt.show()

ValueError: Argument dimensions are incompatible

nope!

1
  • Yup! range(0,100) and range(10,100) don't have the same dimensions. Commented Dec 4, 2015 at 12:10

1 Answer 1

1

I don't think that you need masked arrays for that.. I'm not sure if this completely matches your goal, but e.g.:

import matplotlib.pyplot as plt

x = np.arange(0,255,0.1)
y = np.arange(0,255,0.1)

plt.plot(x,y)
plt.fill_between(x, y1=10, y2=255, where=x<100)  
plt.show()
Sign up to request clarification or add additional context in comments.

8 Comments

its correct for the lower range, but not for upper range since it's not filling the rectangle region.
But with (x < 100) & (y > 10), what is the upper limit of y, and lower limit of x?
y between 10 and 255. x between 0 and 100.
plt.fill_between(x, y1=10, y2=255, where=x<100)?
But in that case, you might also simply draw a filled rectangle
|

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.