Hello, Thanks to quick hints/tips from Eric and Lionel, I have a module for conditional plotting and histogramming without defining a table type! It works with numerical arrays quite well, but does not work on string arrays in conditions.
I paste the code below since they are quite short. Hope that's not considered spam on this list. :) cheers and thanks, Ping from pylab import * def __prepare(arg): cond = arg[-1] indices = find(cond) toplot = [] atype = type(array([0,1])) for vec in arg[:-1]: if type(vec) == type(""): toplot.append(vec) if type(vec) == atype: toplot.append(array([vec[i] for i in indices])) return toplot def cplot(*arg, **kw): '''Make a conditional plot. Example: cplot(t, x, y > 3) => a plot of { (t[i],x[i]) | y[i] > 3} cplot(x, y > 3) => a plot of { (i,x[i]) | y[i] > 3} The condition string can have multiple conditions joined by logical operators & | ^. All keyword arguments are passed intact to plot(). ''' toplot = __prepare(arg) return plot(*toplot, **kw) def chist(*arg, **kw): '''Make a conditional histogram. Example: chist(x, y > 3) => a histogram plot of {x[i] | y[i] > 3} The condition string can have multiple conditions joined by logical operators & | ^. All keyword arguments are passed intact to hist(). ''' toplot = __prepare(arg) return hist(*toplot, **kw) def testcplot(): t = arange(0,1.0, 0.01) x = sin(t*2*pi) y = exp(-t/0.5) plot(t, x) plot(t, y) cplot(t, x, "o", y<0.2) if __name__ == '__main__': testcplot() ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users