Reputation: 227
The following accomplishes what I want:
pylab.scatter(x[z>-99.0], y[z>-99.0], c=z[z>-99.0])
But, for the sake of "Don't Repeat Yourself", I would like something similar to what is shown below. Is this possible in python?
where z>-99.0:
pylab.scatter(x, y, c=z)
Upvotes: 0
Views: 52
Reputation: 22031
If I'm not mistaken, this should do what you want:
i = z > -99.0
pylab.scatter(x[i], y[i], c=z[i])
You could also try this instead:
def where(index, *args):
return tuple(item[index] for item in args)
x, y, z = where(z > -99.0, x, y, z)
pylab.scatter(x, y, c=z)
Upvotes: 1