本文整理汇总了Python中pylab.arange方法的典型用法代码示例。如果您正苦于以下问题:Python pylab.arange方法的具体用法?Python pylab.arange怎么用?Python pylab.arange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylab
的用法示例。
在下文中一共展示了pylab.arange方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import arange [as 别名]
def draw(self):
self.read() #read current values
#self.read_test() #testing reading
print "Plotting..."
if len(self.channels) == 1:
NumberSamples = min(len(self.values), self.scale1.get())
CurrentXAxis = pylab.arange(len(self.values) - NumberSamples, len(self.values), 1)
self.line1[0].set_data(CurrentXAxis, pylab.array(self.values[-NumberSamples:]))
self.ax.axis([CurrentXAxis.min(), CurrentXAxis.max(), 0, 3.5])
elif len(self.channels) == 2:
NumberSamplesx = min(len(self.valuesx), self.scale1.get())
NumberSamplesy = min(len(self.valuesy), self.scale1.get())
self.line1[0].set_data(pylab.array(self.valuesx[-NumberSamplesx:]), pylab.array(self.valuesy[-NumberSamplesy:]))
self.drawing.draw()
self.root.after(25, self.draw)
return
示例2: _increase_contrast
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import arange [as 别名]
def _increase_contrast(image):
"""
Helper function for increasing contrast of image.
"""
# Create a local copy of the image.
copy = image.copy()
maxIntensity = 255.0
x = arange(maxIntensity)
# Parameters for manipulating image data.
phi = 1.3
theta = 1.5
y = (maxIntensity/phi)*(x/(maxIntensity/theta))**0.5
# Decrease intensity such that dark pixels become much darker,
# and bright pixels become slightly dark.
copy = (maxIntensity/phi)*(copy/(maxIntensity/theta))**2
copy = array(copy, dtype=uint8)
return copy
示例3: CAT
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import arange [as 别名]
def CAT(N, rho, k):
r"""Criterion Autoregressive Transfer Function :
.. math:: CAT(k) = \frac{1}{N} \sum_{i=1}^k \frac{1}{\rho_i} - \frac{\rho_i}{\rho_k}
.. todo:: validation
"""
from numpy import zeros, arange
cat = zeros(len(rho))
for p in arange(1, len(rho)+1):
rho_p = float(N)/(N-p)*rho[p-1]
s = 0
for j in range(1, p+1):
rho_j = float(N)/(N-j)*rho[j-1]
s = s + 1./rho_j
#print(s, s/float(N), 1./rho_p)
cat[p-1] = s/float(N) - 1./rho_p
return cat
示例4: compare_lineshapes
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import arange [as 别名]
def compare_lineshapes(wL,wG):
""" create a plot comparing voigt with lorentzian and gaussian
wL and wG are widths of Lorentzian and Gaussian, respectively """
# generate some lineshape to analyse later
x = arange(-20,20,0.01)
yL,yG,yV = generate_lineshapes(x,0,wL,0,wG)
y_noise = random.randn(len(x))*0.1
yV += y_noise
fig = figure(2)
clf()
ax = fig.add_subplot(111)
ax.plot(x,yL/yL.max(),'b',lw=2,label='Lorentzian')
ax.plot(x,yG/yG.max(),'r',lw=2,label='Gaussian')
ax.plot(x,yV/yV.max(),'g--',lw=2,label='Voigt')
# Add legend: loc=0 means find best position
ax.legend(loc=0)
ax.set_xlabel('Detuning (arb.)')
ax.set_ylabel('Intensity (arb.)')
示例5: setup
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import arange [as 别名]
def setup(self, channels):
print "Setting up the channels..."
self.channels = channels
# Setup oscilloscope window
self.root = Tkinter.Tk()
self.root.wm_title("PiScope")
if len(self.channels) == 1:
# Create x and y axis
xAchse = pylab.arange(0, 4000, 1)
yAchse = pylab.array([0]*4000)
# Create the plot
fig = pylab.figure(1)
self.ax = fig.add_subplot(111)
self.ax.set_title("Oscilloscope")
self.ax.set_xlabel("Time")
self.ax.set_ylabel("Amplitude")
self.ax.axis([0, 4000, 0, 3.5])
elif len(self.channels) == 2:
# Create x and y axis
xAchse = pylab.array([0]*4000)
yAchse = pylab.array([0]*4000)
# Create the plot
fig = pylab.figure(1)
self.ax = fig.add_subplot(111)
self.ax.set_title("X-Y Plotter")
self.ax.set_xlabel("Channel " + str(self.channels[0]))
self.ax.set_ylabel("Channel " + str(self.channels[1]))
self.ax.axis([0, 3.5, 0, 3.5])
self.ax.grid(True)
self.line1 = self.ax.plot(xAchse, yAchse, '-')
# Integrate plot on oscilloscope window
self.drawing = FigureCanvasTkAgg(fig, master=self.root)
self.drawing.show()
self.drawing.get_tk_widget().pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1)
# Setup navigation tools
tool = NavigationToolbar2TkAgg(self.drawing, self.root)
tool.update()
self.drawing._tkcanvas.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1)
return
示例6: MDL
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import arange [as 别名]
def MDL(N, rho, k):
r"""Minimum Description Length
.. math:: MDL(k) = N log \rho_k + p \log N
:validation: results
"""
from numpy import log
#p = arange(1, len(rho)+1)
mdl = N* log(rho) + k * log(N)
return mdl
示例7: replotf
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import arange [as 别名]
def replotf(self):
"""This replots the function given the coefficient array c."""
x = M.arange(-1,1.,.001)
M.ioff()
M.figure(self.ffig.number)
M.cla()
M.plot(x, f(x,self.c))
M.title(fstring(self.c))
M.draw()
示例8: main
# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import arange [as 别名]
def main(wL,wG):
#generate data
x = arange(-30,30,0.2)
yL,yG,yV = generate_lineshapes(x,0,wL,0,wG)
y_noise = random.randn(len(x))*0.03
yV += y_noise
fit_lineshape(x,yV)