|
From: thkoe002 <thk...@gm...> - 2009-10-12 16:34:44
|
Maybe a little shorter is the where() keyword, and even that can be omitted: ax.plot(t[where(s>=0)],s[where(s>=0)],"g") ax.plot(t[where(s<0)],s[where(s<0)],"r") or, shorter: ax.plot(t[s>=0],s[s>=0],"g") ax.plot(t[s<0],s[s<0],"r") cheers Thomas Xavier Gnata-2 wrote: > > Hi, > > Imagine you have something like: > > from pylab import * > t = arange(0.0, 2.0, 0.01) > s = sin(2*pi*t) > ax = subplot(111) > ax.plot(t, s) > > That's fine but now I would like to plot the negative parts of the curve > in red and the positive one in green. > Is there a nice pylab oriented way to do that? Some kind of "conditional > formating"? > > Xavier > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- View this message in context: http://www.nabble.com/plot-color-as-a-function-of-values--tp25848622p25858967.html Sent from the matplotlib - users mailing list archive at Nabble.com. |