• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python cbook.silent_list函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中matplotlib.cbook.silent_list函数的典型用法代码示例。如果您正苦于以下问题:Python silent_list函数的具体用法?Python silent_list怎么用?Python silent_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: axes_simpplot3d

def axes_simpplot3d(ax, p, t, pmask=None, **kwargs):
    """Plot a surface or volume triangulation.

    Parameters
    ----------
    p : array, shape (np, 3)
    t : array, shape (nt, 3) or (nt, 4)
    pmask : callable or bool array of shape (np,)

    Additional keyword arguments
    ----------------------------
    facecolor : facecolor
    ifacecolor : facecolor for faces exposed by pmask
    """
    if not ax._hold: ax.cla()
    had_data = ax.has_data()

    facecolor = kwargs.pop('facecolor', (0.8, 0.9, 1.0))
    ifacecolor = kwargs.pop('ifacecolor', (0.9, 0.8, 1.0))
    xs, ys, zs = p.T

    ret = cbook.silent_list('mpl_toolkits.mplot3d.art3d.PathPatch3D')

    if t.shape[1] == 4:
        tri1 = _mkfaces(t)

        if pmask is not None:
            if isinstance(pmask, collections.Callable):
                pmask = pmask(p)
            t = t[pmask[t].any(1)]
            tri2 = _mkfaces(t)
            tri1 = tri1.intersection(tri2)
            tri2 = tri2.difference(tri1)
            c = _trimesh(ax, tri2, xs, ys, zs, facecolor=ifacecolor)
            ret.extend(c)
    else:
        tri1 = t
        if pmask is not None:
            if isinstance(pmask, collections.Callable):
                pmask = pmask(p)
            tri1 = t[pmask[t].any(1)]

    c = _trimesh(ax, tri1, xs, ys, zs, facecolor=facecolor)
    ret.extend(c)
    ax.auto_scale_xyz(xs, ys, zs, had_data)

    return ret
开发者ID:bcrestel,项目名称:pydistmesh,代码行数:47,代码来源:plotting.py


示例2: get_texts

 def get_texts(self):
     'return a list of text.Text instance in the legend'
     return silent_list('Text', self.texts)
开发者ID:EnochManohar,项目名称:matplotlib,代码行数:3,代码来源:legend.py


示例3: get_patches

 def get_patches(self):
     'return a list of patch instances in the legend'
     return silent_list('Patch', [h for h in self.legendHandles if isinstance(h, Patch)])
开发者ID:EnochManohar,项目名称:matplotlib,代码行数:3,代码来源:legend.py


示例4: hist


#.........这里部分代码省略.........
                if bottom is None:
                    bottom = 0.0
                bottom += m
            boffset += dw

    elif histtype.startswith('step'):
        x = np.zeros( 2*len(bins), np.float )
        y = np.zeros( 2*len(bins), np.float )

        x[0::2], x[1::2] = bins, bins

        # FIX FIX FIX
        # This is the only real change.
        # minimum = min(bins)
        if log is True:
            minimum = 1.0
        elif log:
            minimum = float(log)
        else:
            minimum = 0.0
        # FIX FIX FIX end

        if align == 'left' or align == 'center':
            x -= 0.5*(bins[1]-bins[0])
        elif align == 'right':
            x += 0.5*(bins[1]-bins[0])

        if log:
            y[0],y[-1] = minimum, minimum
            if orientation == 'horizontal':
                self.set_xscale('log')
            else:  # orientation == 'vertical'
                self.set_yscale('log')

        fill = (histtype == 'stepfilled')

        for m, c in zip(n, color):
            y[1:-1:2], y[2::2] = m, m
            if log:
                y[y<minimum]=minimum
            if orientation == 'horizontal':
                x,y = y,x

            if fill:
                patches.append( self.fill(x, y,
                    closed=False, facecolor=c) )
            else:
                patches.append( self.fill(x, y,
                    closed=False, edgecolor=c, fill=False) )

        # adopted from adjust_x/ylim part of the bar method
        if orientation == 'horizontal':
            xmin0 = max(_saved_bounds[0]*0.9, minimum)
            xmax = self.dataLim.intervalx[1]
            for m in n:
                xmin = np.amin(m[m!=0]) # filter out the 0 height bins
            xmin = max(xmin*0.9, minimum)
            xmin = min(xmin0, xmin)
            self.dataLim.intervalx = (xmin, xmax)
        elif orientation == 'vertical':
            ymin0 = max(_saved_bounds[1]*0.9, minimum)
            ymax = self.dataLim.intervaly[1]
            for m in n:
                ymin = np.amin(m[m!=0]) # filter out the 0 height bins
            ymin = max(ymin*0.9, minimum)
            ymin = min(ymin0, ymin)
            self.dataLim.intervaly = (ymin, ymax)

    if label is None:
        labels = ['_nolegend_']
    elif is_string_like(label):
        labels = [label]
    elif is_sequence_of_strings(label):
        labels = list(label)
    else:
        raise ValueError(
            'invalid label: must be string or sequence of strings')
    if len(labels) < nx:
        labels += ['_nolegend_'] * (nx - len(labels))

    for (patch, lbl) in zip(patches, labels):
        for p in patch:
            p.update(kwargs)
            p.set_label(lbl)
            lbl = '_nolegend_'

    if binsgiven:
        if orientation == 'vertical':
            self.update_datalim([(bins[0],0), (bins[-1],0)], updatey=False)
        else:
            self.update_datalim([(0,bins[0]), (0,bins[-1])], updatex=False)

    self.set_autoscalex_on(_saved_autoscalex)
    self.set_autoscaley_on(_saved_autoscaley)
    self.autoscale_view()

    if nx == 1:
        return n[0], bins, cbook.silent_list('Patch', patches[0])
    else:
        return n, bins, cbook.silent_list('Lists of Patches', patches)
开发者ID:Moanwar,项目名称:cmssw,代码行数:101,代码来源:mpl_axes_hist_fix.py


示例5: multihist

def multihist(xvals, bins=10, normed=0, bottom=None,
    		   align='edge', orientation='vertical', width=None,
    		   log=False, type='overlap',gap=None, patch_kwargs=None, labels=None, **kwargs):

      #some integrity checks up front
      if type == 'bi' and len(xvals) != 2:
    	  raise ValueError('need exactly two data sets for "bi" multihist: %d given' % len(xvals))
      if patch_kwargs is not None and len(patch_kwargs) != len(xvals):
    	  raise ValueError('need same number of patch kwargs and data sets')

      #calculate the common bins, more or less stolen from numpy.histogram
      xvals = [npy.asarray(x).ravel() for x in xvals]
      if not npy.iterable(bins):
    	  mn = float(min([x.min() for x in xvals]))
    	  mx = float(max([x.max() for x in xvals]))
    	  if mn == mx:
    		  mn -= 0.5
    		  mx += 0.5
    	  bins = npy.linspace(mn, mx, bins, endpoint=False)

      #make the histograms using the common bins
      xn = []
      for x in xvals:
    	  n, bins2 = npy.histogram(x, bins, range=None, normed=normed)
    	  xn.append(n)

      #build the patches parameters depending on type argument
      if width is None: width = 0.9*(bins[1]-bins[0])
      delta = 0
      offset = 0
      paint_width = width
      stay_on_top = True
      if type == 'beside':
    	  if npy.iterable(width):
    		  raise ValueError('no sequence of widths allowed for "beside" multihist')
    	  width /= len(xn)
    	  delta = width
    	  if align == 'edge':
    		  offset = 0
    	  elif align == 'center':
    		  offset = ((len(xn) / -2.0 + 0.5) * width)
    	  else:
    		  raise ValueError('invalid alignment: %s' % align)
    	  if gap is None:
    		  gap = 0
    	  paint_width = width - gap
      elif type == 'bi':
    	  stay_on_top = False
      elif type != 'overlap':
    	  raise ValueError('invalid multihist type: %s' % type)

      #build the patches
      patch_list = []
      on_top = True
      for n in xn:
    	  obins = [b + offset for b in bins]
    	  if on_top:
    		  rn = n
    	  else:
    		  rn = [-v for v in n]
    	  if orientation == 'horizontal':
    		  patches = pylab.barh(obins, rn, height=paint_width, left=bottom,
    								  align=align, log=log)
    	  elif orientation == 'vertical':
			  patches = pylab.bar(obins[:-1], rn, width=paint_width, bottom=bottom,
    							  align=align, log=log, linewidth=0)
    	  else:
    		  raise ValueError('invalid orientation: %s' % orientation)
    	  patch_list.append(cbook.silent_list('Patch', patches))
    	  offset += delta
    	  on_top = on_top and stay_on_top

      for i in range(len(patch_list)):
    	  if patch_kwargs == None:
    		  kwa = kwargs
    	  else:
    		  kwa = patch_kwargs[i]
    		  if labels:
				  lab = labels[i]
    	  for p in patch_list[i]:
    		  p.update(kwa)
		  if labels:
		      patch_list[i][0].update({"label":lab})

      return xn, bins, patch_list
开发者ID:vnoel,项目名称:pycode,代码行数:85,代码来源:multihist.py


示例6: __init__

    def __init__(self, ax, *args, **kwargs):
        """
        Draw contour lines or filled regions, depending on
        whether keyword arg 'filled' is False (default) or True.

        The first argument of the initializer must be an axes
        object.  The remaining arguments and keyword arguments
        are described in ContourSet.contour_doc.

        """
        self.ax = ax
        self.levels = kwargs.get("levels", None)
        self.filled = kwargs.get("filled", False)
        self.linewidths = kwargs.get("linewidths", None)
        self.linestyles = kwargs.get("linestyles", None)

        self.alpha = kwargs.get("alpha", 1.0)
        self.origin = kwargs.get("origin", None)
        self.extent = kwargs.get("extent", None)
        cmap = kwargs.get("cmap", None)
        self.colors = kwargs.get("colors", None)
        norm = kwargs.get("norm", None)
        self.extend = kwargs.get("extend", "neither")
        self.antialiased = kwargs.get("antialiased", True)
        self.nchunk = kwargs.get("nchunk", 0)
        self.locator = kwargs.get("locator", None)
        if isinstance(norm, colors.LogNorm) or isinstance(self.locator, ticker.LogLocator):
            self.logscale = True
            if norm is None:
                norm = colors.LogNorm()
            if self.extend is not "neither":
                raise ValueError("extend kwarg does not work yet with log scale")
        else:
            self.logscale = False

        if self.origin is not None:
            assert self.origin in ["lower", "upper", "image"]
        if self.extent is not None:
            assert len(self.extent) == 4
        if cmap is not None:
            assert isinstance(cmap, colors.Colormap)
        if self.colors is not None and cmap is not None:
            raise ValueError("Either colors or cmap must be None")
        if self.origin == "image":
            self.origin = mpl.rcParams["image.origin"]
        x, y, z = self._contour_args(*args)  # also sets self.levels,
        #  self.layers
        if self.colors is not None:
            cmap = colors.ListedColormap(self.colors, N=len(self.layers))
        if self.filled:
            self.collections = cbook.silent_list("collections.PolyCollection")
        else:
            self.collections = cbook.silent_list("collections.LineCollection")
        # label lists must be initialized here
        self.labelTexts = []
        self.labelCValues = []

        kw = {"cmap": cmap}
        if norm is not None:
            kw["norm"] = norm
        cm.ScalarMappable.__init__(self, **kw)  # sets self.cmap;
        self._process_colors()
        _mask = ma.getmask(z)
        if _mask is ma.nomask:
            _mask = None

        if self.filled:
            if self.linewidths is not None:
                warnings.warn("linewidths is ignored by contourf")
            C = _cntr.Cntr(x, y, z.filled(), _mask)
            lowers = self._levels[:-1]
            uppers = self._levels[1:]
            for level, level_upper in zip(lowers, uppers):
                nlist = C.trace(level, level_upper, points=0, nchunk=self.nchunk)
                col = collections.PolyCollection(
                    nlist, antialiaseds=(self.antialiased,), edgecolors="none", alpha=self.alpha
                )
                self.ax.add_collection(col)
                self.collections.append(col)

        else:
            tlinewidths = self._process_linewidths()
            self.tlinewidths = tlinewidths
            tlinestyles = self._process_linestyles()
            C = _cntr.Cntr(x, y, z.filled(), _mask)
            for level, width, lstyle in zip(self.levels, tlinewidths, tlinestyles):
                nlist = C.trace(level, points=0)
                col = collections.LineCollection(nlist, linewidths=width, linestyle=lstyle, alpha=self.alpha)

                col.set_label("_nolegend_")
                self.ax.add_collection(col, False)
                self.collections.append(col)
        self.changed()  # set the colors
        x0 = ma.minimum(x)
        x1 = ma.maximum(x)
        y0 = ma.minimum(y)
        y1 = ma.maximum(y)
        self.ax.update_datalim([(x0, y0), (x1, y1)])
        self.ax.autoscale_view()
开发者ID:zoccolan,项目名称:eyetracker,代码行数:99,代码来源:contour.py


示例7: clabel


#.........这里部分代码省略.........
        """

        """
        NOTES on how this all works:

        clabel basically takes the input arguments and uses them to
        add a list of "label specific" attributes to the ContourSet
        object.  These attributes currently include: label_indices,
        label_levels, label_cvalues, fp (font properties), fslist
        (fontsize list), label_mappable, cl (list of text objects of
        labels), cl_xy (coordinates of labels), cl_cvalues (color
        values of the actual labels).

        Note that these property names do not conform to the standards
        set for coding matplotlib and I (DMK) eventually plan on
        changing them so that they are clearer and conform to
        standards.

        Once these attributes are set, clabel passes control to the
        labels method (case of automatic label placement) or
        BlockingContourLabeler (case of manual label placement).
        """

        fontsize = kwargs.get('fontsize', None)
        inline = kwargs.get('inline', 1)
        inline_spacing = kwargs.get('inline_spacing', 5)
        self.labelFmt = kwargs.get('fmt', '%1.3f')
        _colors = kwargs.get('colors', None)

        # Detect if manual selection is desired and remove from argument list
        self.labelManual=kwargs.get('manual',False)

        if len(args) == 0:
            levels = self.levels
            indices = range(len(self.levels))
        elif len(args) == 1:
            levlabs = list(args[0])
            indices, levels = [], []
            for i, lev in enumerate(self.levels):
                if lev in levlabs:
                    indices.append(i)
                    levels.append(lev)
            if len(levels) < len(levlabs):
                msg = "Specified levels " + str(levlabs)
                msg += "\n don't match available levels "
                msg += str(self.levels)
                raise ValueError(msg)
        else:
            raise TypeError("Illegal arguments to clabel, see help(clabel)")
        self.labelLevelList = levels
        self.labelIndiceList = indices

        self.labelFontProps = font_manager.FontProperties()
        if fontsize == None:
            font_size = int(self.labelFontProps.get_size_in_points())
        else:
            if type(fontsize) not in [int, float, str]:
                raise TypeError("Font size must be an integer number.")
                # Can't it be floating point, as indicated in line above?
            else:
                if type(fontsize) == str:
                    font_size = int(self.labelFontProps.get_size_in_points())
                else:
                    self.labelFontProps.set_size(fontsize)
                    font_size = fontsize
        self.labelFontSizeList = [font_size] * len(levels)

        if _colors == None:
            self.labelMappable = self
            self.labelCValueList = np.take(self.cvalues, self.labelIndiceList)
        else:
            cmap = colors.ListedColormap(_colors, N=len(self.labelLevelList))
            self.labelCValueList = range(len(self.labelLevelList))
            self.labelMappable = cm.ScalarMappable(cmap = cmap,
                                                   norm = colors.NoNorm())

        #self.labelTexts = []   # Initialized in ContourSet.__init__
        #self.labelCValues = [] # same
        self.labelXYs = []

        if self.labelManual:
            print 'Select label locations manually using first mouse button.'
            print 'End manual selection with second mouse button.'
            if not inline:
                print 'Remove last label by clicking third mouse button.'

            blocking_contour_labeler = BlockingContourLabeler(self)
            blocking_contour_labeler(inline,inline_spacing)
        else:
            self.labels(inline,inline_spacing)

        # Hold on to some old attribute names.  These are depricated and will
        # be moved in the near future (sometime after 2008-08-01), but keeping
        # for now for backwards compatibility
        self.cl = self.labelTexts
        self.cl_xy = self.labelXYs
        self.cl_cvalues = self.labelCValues

        self.labelTextsList =  cbook.silent_list('text.Text', self.labelTexts)
        return self.labelTextsList
开发者ID:Einstein-NTE,项目名称:einstein,代码行数:101,代码来源:contour.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cbook.unicode_safe函数代码示例发布时间:2022-05-27
下一篇:
Python cbook.safezip函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap