当前位置: 首页>>代码示例>>Python>>正文


Python pylab.hold方法代码示例

本文整理汇总了Python中pylab.hold方法的典型用法代码示例。如果您正苦于以下问题:Python pylab.hold方法的具体用法?Python pylab.hold怎么用?Python pylab.hold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pylab的用法示例。


在下文中一共展示了pylab.hold方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: solid_plot

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import hold [as 别名]
def solid_plot():
	# reference values, see
	sref=0.0924102
	wref=0.000170152
	# List of the element types to process (text files)
	eltyps=["C3D8",
		"C3D8R",
		"C3D8I",
		"C3D20",
		"C3D20R",
		"C3D4",
		"C3D10"]
	pylab.figure(figsize=(10, 5.0), dpi=100)
	pylab.subplot(1,2,1)
	pylab.title("Stress")
	# pylab.hold(True) # deprecated
	for elty in eltyps:
		data = numpy.genfromtxt(elty+".txt")
		pylab.plot(data[:,1],data[:,2]/sref,"o-")
	pylab.xscale("log")
	pylab.xlabel('Number of nodes')
	pylab.ylabel('Max $\sigma / \sigma_{\mathrm{ref}}$')
	pylab.grid(True)
	pylab.subplot(1,2,2)
	pylab.title("Displacement")
	# pylab.hold(True) # deprecated
	for elty in eltyps:
		data = numpy.genfromtxt(elty+".txt")
		pylab.plot(data[:,1],data[:,3]/wref,"o-")
	pylab.xscale("log")
	pylab.xlabel('Number of nodes')
	pylab.ylabel('Max $u / u_{\mathrm{ref}}$')
	pylab.ylim([0,1.2])
	pylab.grid(True)
	pylab.legend(eltyps,loc="lower right")
	pylab.tight_layout()
	pylab.savefig("solid.svg",format="svg")
	# pylab.show()


# Move new files and folders to 'Refs' 
开发者ID:mkraska,项目名称:CalculiX-Examples,代码行数:43,代码来源:test.py

示例2: _test_graph

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import hold [as 别名]
def _test_graph():
    i = 10000
    x = np.linspace(0,3.7*pi,i)
    y = (0.3*np.sin(x) + np.sin(1.3 * x) + 0.9 * np.sin(4.2 * x) + 0.06 *
    np.random.randn(i))
    y *= -1
    x = range(i)

    _max, _min = peakdetect(y,x,750, 0.30)
    xm = [p[0] for p in _max]
    ym = [p[1] for p in _max]
    xn = [p[0] for p in _min]
    yn = [p[1] for p in _min]

    plot = pylab.plot(x,y)
    pylab.hold(True)
    pylab.plot(xm, ym, 'r+')
    pylab.plot(xn, yn, 'g+')

    _max, _min = peak_det_bad.peakdetect(y, 0.7, x)
    xm = [p[0] for p in _max]
    ym = [p[1] for p in _max]
    xn = [p[0] for p in _min]
    yn = [p[1] for p in _min]
    pylab.plot(xm, ym, 'y*')
    pylab.plot(xn, yn, 'k*')
    pylab.show() 
开发者ID:MonsieurV,项目名称:py-findpeaks,代码行数:29,代码来源:peakdetect.py

示例3: peakdetect_parabole

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import hold [as 别名]
def peakdetect_parabole(y_axis, x_axis, points = 9):
    """
    Function for detecting local maximas and minmias in a signal.
    Discovers peaks by fitting the model function: y = k (x - tau) ** 2 + m
    to the peaks. The amount of points used in the fitting is set by the
    points argument.

    Omitting the x_axis is forbidden as it would make the resulting x_axis
    value silly if it was returned as index 50.234 or similar.

    will find the same amount of peaks as the 'peakdetect_zero_crossing'
    function, but might result in a more precise value of the peak.

    keyword arguments:
    y_axis -- A list containg the signal over which to find peaks
    x_axis -- A x-axis whose values correspond to the y_axis list and is used
        in the return to specify the postion of the peaks.
    points -- (optional) How many points around the peak should be used during
        curve fitting, must be odd (default: 9)

    return -- two lists [max_peaks, min_peaks] containing the positive and
        negative peaks respectively. Each cell of the lists contains a list
        of: (position, peak_value)
        to get the average peak value do: np.mean(max_peaks, 0)[1] on the
        results to unpack one of the lists into x, y coordinates do:
        x, y = zip(*max_peaks)
    """
    # check input data
    x_axis, y_axis = _datacheck_peakdetect(x_axis, y_axis)
    # make the points argument odd
    points += 1 - points % 2
    #points += 1 - int(points) & 1 slower when int conversion needed

    # get raw peaks
    max_raw, min_raw = peakdetect_zero_crossing(y_axis)

    # define output variable
    max_peaks = []
    min_peaks = []

    max_ = _peakdetect_parabole_fitter(max_raw, x_axis, y_axis, points)
    min_ = _peakdetect_parabole_fitter(min_raw, x_axis, y_axis, points)

    max_peaks = map(lambda x: [x[0], x[1]], max_)
    max_fitted = map(lambda x: x[-1], max_)
    min_peaks = map(lambda x: [x[0], x[1]], min_)
    min_fitted = map(lambda x: x[-1], min_)


    #pylab.plot(x_axis, y_axis)
    #pylab.hold(True)
    #for max_p, max_f in zip(max_peaks, max_fitted):
    #    pylab.plot(max_p[0], max_p[1], 'x')
    #    pylab.plot(max_f[0], max_f[1], 'o', markersize = 2)
    #for min_p, min_f in zip(min_peaks, min_fitted):
    #    pylab.plot(min_p[0], min_p[1], 'x')
    #    pylab.plot(min_f[0], min_f[1], 'o', markersize = 2)
    #pylab.show()

    return [max_peaks, min_peaks] 
开发者ID:MonsieurV,项目名称:py-findpeaks,代码行数:62,代码来源:peakdetect.py

示例4: plot_item

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import hold [as 别名]
def  plot_item(self, m, ind, x, r, k, label, U, scores):
    """plot_item(self, m, ind, x, r, k, label, U, scores)

    Plot selection m (index ind, data in x) and its reconstruction r,
    with k and label to annotate the plot.

    U and scores are optional; ignored in this method, used in some
    classes' submethods.
    """

    if x == [] or r == []: 
      print "Error: No data in x and/or r."
      return
  
    im = Image.fromarray(x.reshape(self.winsize, self.winsize, 3))
    outdir  = os.path.join('results', self.name)
    if not os.path.exists(outdir):
      os.mkdir(outdir)
    figfile = os.path.join(outdir, '%s-sel-%d-k-%d.pdf' % (self.name, m, k))
    im.save(figfile)
    print 'Wrote plot to %s' % figfile

    # record the selections in order, at their x,y coords
    # subtract selection number from n so first sels have high values
    mywidth  = self.width - self.winsize
    myheight = self.height - self.winsize
    # set all unselected items to a value 1 less than the latest
    priority = mywidth*myheight - m
    if priority < 2:
      priority = 2
    self.selections[np.where(self.selections < priority)] = priority-2
    (y,x) = map(int, label.strip('()').split(','))
    #self.selections[ind/mywidth, ind%myheight] = priority
    qtrwin = self.winsize/8
    self.selections[y-qtrwin:y+qtrwin, x-qtrwin:x+qtrwin] = priority
    
    pylab.clf()
    pylab.imshow(self.image)
    pylab.hold(True)
    #pylab.imshow(self.selections)
    masked_sels = np.ma.masked_where(self.selections < priority, self.selections)
    pylab.imshow(masked_sels, interpolation='none', alpha=0.5)
    #figfile = '%s/%s-priority-%d-k-%d.pdf' % (outdir, self.name, m, k)
    # Has to be .png or the alpha transparency doesn't work! (pdf)
    figfile = os.path.join(outdir, '%s-priority-k-%d.png' % (self.name, k))
    pylab.savefig(figfile)
    print 'Wrote selection priority plot to %s' % figfile 
开发者ID:wkiri,项目名称:DEMUD,代码行数:49,代码来源:dataset_tc.py


注:本文中的pylab.hold方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。