I have to select values from a scatter plot within a box. So basically I need all the values of the points within the box
N = 500
x = np.random.rand(N) * 2
y = np.random.rand(N) * 2.5
area = np.pi*3
colors = (0,0,0)
fig = plt.figure()
ax1 = fig.add_subplot(111)
plt.scatter(x, y, s=area, alpha=0.5)
plt.xlim(0.0, 2.0)
plt.ylim(0.0, 2.5)
plt.plot([0.7,1.0], [1.15,1.45], 'k--', lw=2)
plt.plot([0.3,0.6], [1.65,1.95], 'k--', lw=2)
plt.plot([0.7,0.3], [1.15, 1.65], 'k--', lw=2)
plt.plot([1.0, 0.6], [1.45, 1.95], 'k--', lw=2)
plt.title('Scatter Plot')
plt.xlabel('X')
plt.ylabel('Y')
This is similar to one of my previous questions Selecting points within a region of a scatter plot
But I am having trouble thinking of how to do it for the box instead of a polygon. I tried doing my steps before but when I try to color them different to show that I am properly selecting the points within the region, the coloration is not correct. Any help would be awesome!