I have a 2-D array and I need to plot columns x and y but only within a certain range of x. I know how to plot using the index but I need to specify the value of x. I have a few of those arrays so I am trying to find a way to do that without having to look at each one of them individually.
Here is an example:
array([[ 4.40148390e+03, 1.13200000e+00],
[ 4.40248390e+03, 1.12200000e+00],
[ 4.40348440e+03, 1.11600000e+00],
[ 4.40448440e+03, 1.10600000e+00],
[ 4.40548490e+03, 1.09200000e+00],
[ 4.40648490e+03, 1.07700000e+00],
[ 4.40748540e+03, 1.08700000e+00],
[ 4.40848540e+03, 1.09400000e+00],
[ 4.40948580e+03, 1.10200000e+00],
[ 4.41048580e+03, 1.09500000e+00],
[ 4.41148630e+03, 1.12000000e+00]])
So let's say I only need 4402 < x < 4410 but I don't know the index. Can I put something like: plot(x, y, where(4402 < x < 4410))?
I feel like there is something obvious that I am missing here :p
You could use matplotlib to set limits on your x-axis so as not to display all the points in your data series. However, we can filter your numpy array above as follows:
a = array([[ .... ]])
x = a[:,0]
y = a[:,1]
filter = (x>4402)&(x<4410)
plot(x[filter],y[filter])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With