From: Pierre GM <bac...@gm...> - 2008-10-27 22:59:43
|
On Monday 27 October 2008 18:40:07 marcusantonius wrote: > I'm sorry for this newbie question. I have a data file consisting of 3 > columns, and want to plot the first versus the second column, but only if > the parameter in the third column lies in a certain range. Does somebody > have an idea how to do that? Using masked arrays ? import numpy as np import numpy as ma import matplotlib.pyplot as mpl x = ma.arange(10) y = ma.array(np.random.rand(10)) z = ma.array(np.random.rand(10)) (z_lo, z_up) = (0.1, 0.8) x[ (z<z_lo) | (z>z_up) ] = ma.masked mpl.plot(x,y, 'ok-') Alternatively, x = ma.masked_where((z<z_lo) | (z>z_up), x) |