matplotlib 画图

来源:互联网 发布:程序员专用计算器 编辑:程序博客网 时间:2024/05/17 04:14
# use masked arrays to plot a line with different colors by y-valuefrom numpy import logical_or, arange, sin, pifrom numpy import mafrom matplotlib.pyplot import  plot, showt = arange(0.0, 2.0, 0.01)s = sin(2*pi*t)upper = 0.77lower = -0.77supper = ma.masked_where(s < upper, s)slower = ma.masked_where(s > lower, s)smiddle = ma.masked_where(logical_or(s<lower, s>upper), s)plot(t, slower, 'r', t, smiddle, 'b', t, supper, 'g')show()
 
http://matplotlib.org/examples/pylab_examples/color_by_yvalue.html
http://matplotlib.org/examples/pylab_examples/color_by_yvalue.html
http://matplotlib.org/examples/pylab_examples/color_by_yvalue.html
http://matplotlib.org/examples/pylab_examples/color_by_yvalue.html
原创粉丝点击