def _make_verts(self, U, V): uv = U+V*1j uv = nx.ravel(nx.ma.filled(uv, nx.nan)) a = nx.absolute(uv) if self.scale is None: sn = max(10, math.sqrt(self.N)) scale = 1.8 * nx.average(a) * sn # crude auto-scaling scale = scale/self.span self.scale = scale length = a/(self.scale*self.width) X, Y = self._h_arrows(length) xy = (X+Y*1j) * nx.exp(1j*nx.angle(uv[...,nx.newaxis]))*self.width xy = xy[:,:,nx.newaxis] XY = nx.concatenate((xy.real, xy.imag), axis=2) return XY
def boltzman(x, xmid, tau): """ evaluate the boltzman function with midpoint xmid and time constant tau over x """ return 1. / (1. + nx.exp(-(x - xmid) / tau))
def boltzman(x, xmid, tau): """ evaluate the boltzman function with midpoint xmid and time constant tau over x """ return 1. / (1. + nx.exp(-(x-xmid)/tau))
# # Multiple line plots # =================== # # Often one wants to plot many signals over one another. There are a few # ways to do this. The naive implementation is just to add a constant # offset to each signal: # # <codecell> from pylab import plot, show, ylim, yticks from matplotlib.numerix import sin, cos, exp, pi, arange t = arange(0.0, 2.0, 0.01) s1 = sin(2 * pi * t) s2 = exp(-t) s3 = sin(2 * pi * t) * exp(-t) s4 = sin(2 * pi * t) * cos(4 * pi * t) t = arange(0.0, 2.0, 0.01) plot(t, s1, t, s2 + 1, t, s3 + 2, t, s4 + 3, color='k') ylim(-1, 4) yticks(arange(4), ['S1', 'S2', 'S3', 'S4']) show() # <markdowncell> # but then it is difficult to do change the y scale in a reasonable way. # For example when you zoom in on y, the signals on top and bottom will go # off the screen. Often what one wants is for the y location of each
def f(t): s1 = sin(2 * pi * t) e1 = exp(-t) return absolute(multiply(s1, e1)) + .05
def f(t): s1 = sin(2*pi*t) e1 = exp(-t) return absolute(multiply(s1,e1))+.05
# =================== # # Often one wants to plot many signals over one another. There are a few # ways to do this. The naive implementation is just to add a constant # offset to each signal: # # <codecell> from pylab import plot, show, ylim, yticks from matplotlib.numerix import sin, cos, exp, pi, arange t = arange(0.0, 2.0, 0.01) s1 = sin(2*pi*t) s2 = exp(-t) s3 = sin(2*pi*t)*exp(-t) s4 = sin(2*pi*t)*cos(4*pi*t) t = arange(0.0, 2.0, 0.01) plot(t, s1, t, s2+1, t, s3+2, t, s4+3, color='k') ylim(-1,4) yticks(arange(4), ['S1', 'S2', 'S3', 'S4']) show() # <markdowncell> # but then it is difficult to do change the y scale in a reasonable way. # For example when you zoom in on y, the signals on top and bottom will go # off the screen. Often what one wants is for the y location of each