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


Python LineCollection.set_transform方法代码示例

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


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

示例1: changeVecteur

# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import set_transform [as 别名]
 def changeVecteur(self, ech=1.0, col=None):
     """ modifie les valeurs de vecteurs existants"""
     self.drawVecteur(False)
     if type(ech) == type((3, 4)):
         if len(ech) >= 1:
             ech = ech[0]
     # previous object
     obj = self.getObjFromType("vecteur")
     if obj == None:
         return
     # change coordinates
     dep, arr_old, ech_old = obj.getData()
     arr = dep + (arr_old - dep) * ech / ech_old
     # new object
     lc1 = LineCollection(zip(dep, arr))
     lc1.set_transform(self.transform)
     if col == None:
         col = wx.Color(0, 0, 255)
     a = col.Get()
     col = (a[0] / 255, a[1] / 255, a[2] / 255)
     lc1.set_color(col)
     obj = GraphicObject("vecteur", lc1, False, None)
     obj.setData([dep, arr, ech])
     self.addGraphicObject(obj)
     self.cnv.collections[0] = lc1
     self.redraw()
开发者ID:apryet,项目名称:ipht3d,代码行数:28,代码来源:Visualisation.py

示例2: shape

# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import set_transform [as 别名]
 def shape(self, height, yrange, rotated):
     g = rlg2mpl.Group()
     trans = TransformScalePart(g.combined_transform)
     y = height/2.0
     segments = [[(x1,y),(x2,y)] for (x1,x2) in self.segments]
     a = LineCollection(segments, edgecolor='k', facecolor='k')
     a.set_linewidth(2)
     g.add(a)
     a.set_transform(g.combined_transform)
     return g
开发者ID:GavinHuttley,项目名称:pycogent,代码行数:12,代码来源:linear.py

示例3: shape

# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import set_transform [as 别名]
 def shape(self, height, yrange, rotated):
     g = rlg2mpl.Group()
     trans = TransformScalePart(g.combined_transform)
     segment = [(0.1, 0), (0.9, 0)]
     if rotated:
         segment = [(y, x) for (x, y) in segment]
     a = LineCollection([segment], colors=self.cvalues, offsets=self.offsets, transOffset=g.combined_transform)
     a.set_linewidth(3)
     g.add(a)
     a.set_transform(trans)
     return g
开发者ID:pombredanne,项目名称:pycogent-1,代码行数:13,代码来源:linear.py

示例4: make_range_frame

# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import set_transform [as 别名]
    def make_range_frame(self):

        xminf, xmaxf = data_bounds_on_axis(self.axes.viewLim.intervalx, self.xbounds)

        yminf, ymaxf = data_bounds_on_axis(self.axes.viewLim.intervaly, self.ybounds)

        xline = [(xminf, 0), (xmaxf, 0)]
        yline = [(0, yminf), (0, ymaxf)]

        range_lines = LineCollection(segments=[xline, yline], linewidths=[self.linewidth], colors=[self.color])

        range_lines.set_transform(self.axes.transAxes)
        range_lines.set_zorder(10)

        return range_lines
开发者ID:AstroVPK,项目名称:DissertationDocs,代码行数:17,代码来源:pylab_params.py

示例5: make_range_frame

# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import set_transform [as 别名]
    def make_range_frame (self):

        rx = self.axes.get_xlim()
        ry = self.axes.get_ylim()
        px = pl.prctile ( self.x )
        py = pl.prctile ( self.y )

        if self.trim:
            if px[2]-px[0]>1.5*(px[3]-px[1]):
                px[0] = self.x[self.x>px[2]-1.5*(px[3]-px[1])].min()
            if px[4]-px[2]>1.5*(px[3]-px[1]):
                px[4] = self.x[self.x<px[2]+1.5*(px[3]-px[1])].min()

        x = px-rx[0]
        x /= rx[1]-rx[0]
        y = py-ry[0]
        y /= ry[1]-ry[0]
        ex = .003
        ey = .003
        xline = [
                [(x[0],0),(x[1],0)],
                [(x[1],ey),(x[2]-ex,ey)],
                [(x[2]+ex,ey),(x[3],ey)],
                [(x[3],0),(x[4],0)]
                ]
        yline = [
                [(0,y[0]),(0,y[1])],
                [(ex,y[1]),(ex,y[2]-ey)],
                [(ex,y[2]+ey),(ex,y[3])],
                [(0,y[3]),(0,y[4])]
                ]
        widths = [1,1,1,1]
        range_lines = LineCollection(
                segments=pl.clip(xline+yline,0,1),
                linewidths=widths+widths,
                colors=[[0]*3]*2*len(widths) )
        range_lines.set_transform ( self.axes.transAxes )
        range_lines.set_zorder(10)

        self.axes.get_xaxis().tick_bottom()
        self.axes.get_yaxis().tick_left()
        self.axes.set_xticks(px)
        self.axes.set_yticks(py)
        self.axes.tick_params ( width=0 )

        return range_lines
开发者ID:igordertigor,项目名称:dvis,代码行数:48,代码来源:customized.py

示例6: make_box_plot

# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import set_transform [as 别名]
 def make_box_plot (self):
     x = self.x
     rx = self.axes.get_xlim()
     ry = self.axes.get_ylim()
     ex = self.offset*(rx[1]-rx[0])
     ey = self.offset*(ry[1]-ry[0])
     if self.vert == 1:
         ex,ey = ey,ex
     p = self.boxstats['main']
     n = self.boxstats['notch']
     f_lo,f_hi = self.boxstats['fliers']
     if self.notch:
         lines = [ [(x,p[0]),(x,p[1])],
                 [(x+ex,p[1]),(x+ex,n[0])],
                 [(x+ex,n[0]),(x-ex,p[2]-ey)],
                 [(x-ex,p[2]+ey),(x+ex,n[1])],
                 [(x+ex,n[1]),(x+ex,p[3])],
                 [(x,p[3]),(x,p[4])] ]
     else:
         lines = [ [(x,p[0]),(x,p[1])],
                 [(x+ex,p[1]),(x+ex,p[2]-ey)],
                 [(x+ex,p[2]+ey),(x+ex,p[3])],
                 [(x,p[3]),(x,p[4])] ]
     lines = pl.array(lines)
     if self.vert==1:
         lines = pl.array([ pl.c_[l[:,1],l[:,0]] for l in lines ])
         pt = self.axes.plot ( f_lo, [x]*len(f_lo), '.', color=self.color,
                 markersize=self.lw ) + \
             self.axes.plot ( f_hi, [x]*len(f_hi), '.', color=self.color,
                 markersize=self.lw )
         dummy = self.axes.plot ( [p[0],p[-1]],[x-ex,x+ex], '.', markersize=0 )
     else:
         pt = self.axes.plot ( [x]*len(f_lo), f_lo, '.', color=self.color,
                 markersize=1 ) + \
             self.axes.plot ( [x]*len(f_hi), f_hi, '.', color=self.color,
                 markersize=1 )
         dummy = self.axes.plot ( [x-ex,x+ex], [p[0],p[-1]], '.', markersize=0 )
     box = LineCollection (
             segments=lines,
             linewidths=[self.lw]*lines.shape[0],
             colors=[self.color]*lines.shape[0] )
     box.set_transform ( self.axes.transData )
     box.set_zorder(10)
     return box, pt[0],dummy[0]
开发者ID:igordertigor,项目名称:dvis,代码行数:46,代码来源:customized.py

示例7: createVecteur

# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import set_transform [as 别名]
 def createVecteur(self, X, Y, U, V, ech=1.0, col=None):
     """ modifie les valeurs de vecteurs existants"""
     self.drawVecteur(False)
     # print shape(X),shape(Y),shape(U),shape(V)
     # new coordinates
     # vm = mean(median(median(U)),median(median(V)));
     # dmx = max(X[0,1]-X[0,0],Y[0,1]-Y[0,0])
     u, v = U, V  # /vm*dmx*ech/2
     l = len(ravel(X))
     dep = concatenate([X.reshape((l, 1)), Y.reshape((l, 1))], axis=1)
     b = X + u
     c = Y + v
     arr = concatenate([b.reshape((l, 1)), c.reshape((l, 1))], axis=1)
     lc1 = LineCollection(zip(dep, arr))
     lc1.set_transform(self.transform)
     obj = GraphicObject("vecteur", lc1, False, None)
     obj.setData([dep, arr, ech])
     self.addGraphicObject(obj)
     if len(self.cnv.collections) > 0:
         self.cnv.collections[0] = lc1
     else:
         self.cnv.collections = [lc1]
     self.redraw()
开发者ID:apryet,项目名称:ipht3d,代码行数:25,代码来源:Visualisation.py

示例8: initDomain

# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import set_transform [as 别名]
    def initDomain(self):
        # changement de la valeur des axes
        grd = self.model.Aquifere.getFullGrid()
        self.xlim = (grd["x0"], grd["x1"])
        self.ylim = (grd["y0"], grd["y1"])
        p, = pl.plot([0, 1], "b")
        self.transform = p.get_transform()
        obj = GraphicObject("grille", p, True, None)
        self.addGraphicObject(obj)
        self.changeDomain()

        # add basic vector as a linecollection
        dep = rand(2, 2) * 0.0
        arr = dep * 1.0
        ech = 1.0
        lc1 = LineCollection(zip(dep, arr))
        lc1.set_transform(self.transform)
        pl.setp(lc1, linewidth=0.5)
        self.cnv.collections = [lc1]
        # self.cnv.add_patch(lc1);
        obj = GraphicObject("vecteur", lc1, False, None)
        obj.setData([dep, arr, ech])
        self.addGraphicObject(obj)
        self.draw()
开发者ID:apryet,项目名称:ipht3d,代码行数:26,代码来源:Visualisation.py

示例9: plot_day_summary2

# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import set_transform [as 别名]
def plot_day_summary2(ax, opens, closes, highs, lows, ticksize=4,
                      colorup='k', colordown='r',
                     ):
    """

    Represent the time, open, close, high, low as a vertical line
    ranging from low to high.  The left tick is the open and the right
    tick is the close.

    ax          : an Axes instance to plot to
    ticksize    : size of open and close ticks in points
    colorup     : the color of the lines where close >= open
    colordown   : the color of the lines where close <  open

    return value is a list of lines added
    """

    # note this code assumes if any value open, close, low, high is
    # missing they all are missing

    rangeSegments = [ ((i, low), (i, high)) for i, low, high in zip(xrange(len(lows)), lows, highs) if low != -1 ]

    # the ticks will be from ticksize to 0 in points at the origin and
    # we'll translate these to the i, close location
    openSegments = [  ((-ticksize, 0), (0, 0)) ]

    # the ticks will be from 0 to ticksize in points at the origin and
    # we'll translate these to the i, close location
    closeSegments = [ ((0, 0), (ticksize, 0)) ]


    offsetsOpen = [ (i, open) for i, open in zip(xrange(len(opens)), opens) if open != -1 ]

    offsetsClose = [ (i, close) for i, close in zip(xrange(len(closes)), closes) if close != -1 ]


    scale = ax.figure.dpi * (1.0/72.0)

    tickTransform = Affine2D().scale(scale, 0.0)

    r,g,b = colorConverter.to_rgb(colorup)
    colorup = r,g,b,1
    r,g,b = colorConverter.to_rgb(colordown)
    colordown = r,g,b,1
    colord = { True : colorup,
               False : colordown,
               }
    colors = [colord[open<close] for open, close in zip(opens, closes) if open!=-1 and close !=-1]

    assert(len(rangeSegments)==len(offsetsOpen))
    assert(len(offsetsOpen)==len(offsetsClose))
    assert(len(offsetsClose)==len(colors))

    useAA = 0,   # use tuple here
    lw = 1,      # and here
    rangeCollection = LineCollection(rangeSegments,
                                     colors       = colors,
                                     linewidths   = lw,
                                     antialiaseds = useAA,
                                     )

    openCollection = LineCollection(openSegments,
                                    colors       = colors,
                                    antialiaseds = useAA,
                                    linewidths   = lw,
                                    offsets      = offsetsOpen,
                                    transOffset  = ax.transData,
                                   )
    openCollection.set_transform(tickTransform)

    closeCollection = LineCollection(closeSegments,
                                     colors       = colors,
                                     antialiaseds = useAA,
                                     linewidths   = lw,
                                     offsets      = offsetsClose,
                                     transOffset  = ax.transData,
                                     )
    closeCollection.set_transform(tickTransform)

    minpy, maxx = (0, len(rangeSegments))
    miny = min([low for low in lows if low !=-1])
    maxy = max([high for high in highs if high != -1])
    corners = (minpy, miny), (maxx, maxy)
    ax.update_datalim(corners)
    ax.autoscale_view()

    # add these last
    ax.add_collection(rangeCollection)
    ax.add_collection(openCollection)
    ax.add_collection(closeCollection)
    return rangeCollection, openCollection, closeCollection
开发者ID:mgiuca-google,项目名称:matplotlib,代码行数:93,代码来源:finance.py

示例10: plot_day_summary2_ohlc

# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import set_transform [as 别名]
def plot_day_summary2_ohlc(ax, opens, highs, lows, closes, ticksize=4,
                          colorup='k', colordown='r',
                          ):

    """Represent the time, open, high, low, close as a vertical line
    ranging from low to high.  The left tick is the open and the right
    tick is the close.
    *opens*, *highs*, *lows* and *closes* must have the same length.
    NOTE: this code assumes if any value open, high, low, close is
    missing (*-1*) they all are missing

    Parameters
    ----------
    ax : `Axes`
        an Axes instance to plot to
    opens : sequence
        sequence of opening values
    highs : sequence
        sequence of high values
    lows : sequence
        sequence of low values
    closes : sequence
        sequence of closing values
    ticksize : int
        size of open and close ticks in points
    colorup : color
        the color of the lines where close >= open
    colordown : color
         the color of the lines where close <  open

    Returns
    -------
    ret : list
        a list of lines added to the axes
    """

    _check_input(opens, highs, lows, closes)

    rangeSegments = [((i, low), (i, high)) for i, low, high in
                     zip(xrange(len(lows)), lows, highs) if low != -1]

    # the ticks will be from ticksize to 0 in points at the origin and
    # we'll translate these to the i, close location
    openSegments = [((-ticksize, 0), (0, 0))]

    # the ticks will be from 0 to ticksize in points at the origin and
    # we'll translate these to the i, close location
    closeSegments = [((0, 0), (ticksize, 0))]

    offsetsOpen = [(i, open) for i, open in
                   zip(xrange(len(opens)), opens) if open != -1]

    offsetsClose = [(i, close) for i, close in
                    zip(xrange(len(closes)), closes) if close != -1]

    scale = ax.figure.dpi * (1.0 / 72.0)

    tickTransform = Affine2D().scale(scale, 0.0)

    colorup = mcolors.to_rgba(colorup)
    colordown = mcolors.to_rgba(colordown)
    colord = {True: colorup, False: colordown}
    colors = [colord[open < close] for open, close in
              zip(opens, closes) if open != -1 and close != -1]

    useAA = 0,   # use tuple here
    lw = 1,      # and here
    rangeCollection = LineCollection(rangeSegments,
                                     colors=colors,
                                     linewidths=lw,
                                     antialiaseds=useAA,
                                     )

    openCollection = LineCollection(openSegments,
                                    colors=colors,
                                    antialiaseds=useAA,
                                    linewidths=lw,
                                    offsets=offsetsOpen,
                                    transOffset=ax.transData,
                                    )
    openCollection.set_transform(tickTransform)

    closeCollection = LineCollection(closeSegments,
                                     colors=colors,
                                     antialiaseds=useAA,
                                     linewidths=lw,
                                     offsets=offsetsClose,
                                     transOffset=ax.transData,
                                     )
    closeCollection.set_transform(tickTransform)

    minpy, maxx = (0, len(rangeSegments))
    miny = min([low for low in lows if low != -1])
    maxy = max([high for high in highs if high != -1])
    corners = (minpy, miny), (maxx, maxy)
    ax.update_datalim(corners)
    ax.autoscale_view()

    # add these last
    ax.add_collection(rangeCollection)
#.........这里部分代码省略.........
开发者ID:NigelKB,项目名称:matplotlib,代码行数:103,代码来源:finance.py


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