Esempio n. 1
0
 def _set_transform(self):
     ax = self.ax
     if self.units in ('x', 'y'):
         if self.units == 'x':
             dx0 = ax.viewLim.ur().x() - ax.viewLim.ll().x()
             dx1 = ax.bbox.ur().x() - ax.bbox.ll().x()
         else:
             dx0 = ax.viewLim.ur().y() - ax.viewLim.ll().y()
             dx1 = ax.bbox.ur().y() - ax.bbox.ll().y()
         dx = dx1/dx0
     else:
         if self.units == 'width':
             dx = ax.bbox.ur().x() - ax.bbox.ll().x()
         elif self.units == 'height':
             dx = ax.bbox.ur().y() - ax.bbox.ll().y()
         elif self.units == 'dots':
             dx = T.Value(1)
         elif self.units == 'inches':
             dx = ax.figure.dpi
         else:
             raise ValueError('unrecognized units')
     bb = T.Bbox(T.origin(), T.Point(dx, dx))
     trans = T.get_bbox_transform(T.unit_bbox(), bb)
     self.set_transform(trans)
     return trans
Esempio n. 2
0
 def _set_transform(self):
     if self.coord == 'data':
         self.set_transform(self.Q.ax.transData)
     elif self.coord == 'axes':
         self.set_transform(self.Q.ax.transAxes)
     elif self.coord == 'figure':
         self.set_transform(self.Q.ax.figure.transFigure)
     elif self.coord == 'inches':
         dx = ax.figure.dpi
         bb = T.Bbox(T.origin(), T.Point(dx, dx))
         trans = T.get_bbox_transform(T.unit_bbox(), bb)
         self.set_transform(trans)
     else:
         raise ValueError('unrecognized coordinates')
Esempio n. 3
0
def rand_transform():
    b1 = rand_bbox()
    b2 = rand_bbox()
    return get_bbox_transform(b1, b2)
Esempio n. 4
0
x = rand(20)
y = rand(20)
transform = identity_transform()
xout, yout = transform.seq_x_y(x,y)
assert((x,y) == transform.seq_x_y(x,y))


# test bbox transforms; transform the unit coordinate system to
# "display coords"
bboxin = unit_bbox()
ll = Point( Value(10),  Value(10) )
ur = Point( Value(200), Value(40) )
bboxout = Bbox(ll, ur)

transform = get_bbox_transform(bboxin, bboxout)

assert( transform.xy_tup( (0,0) )==(10, 10))
assert( transform.xy_tup( (1,1) )==(200, 40))
assert( transform.xy_tup( (0.5, 0.5) )==(105, 25))

# simulate a resize
ur.x().set(400)
ur.y().set(400)
assert( transform.xy_tup( (0,0) )==(10, 10))
assert( transform.xy_tup( (1,1) )==(400, 400))
assert( transform.xy_tup( (0.5, 0.5) )==(205, 205))

pairs = ( ( (0,   0  ), (10,  10 )  ),
          ( (1,   1  ), (400, 400) ),
          ( (0.5, 0.5), (205, 205) ) )
Esempio n. 5
0
def rand_transform():
    b1 = rand_bbox()
    b2 = rand_bbox()
    return get_bbox_transform(b1, b2)
Esempio n. 6
0
assert (a1.xy_tup(pnt) == (7, 60))

x = rand(20)
y = rand(20)
transform = identity_transform()
xout, yout = transform.seq_x_y(x, y)
assert ((x, y) == transform.seq_x_y(x, y))

# test bbox transforms; transform the unit coordinate system to
# "display coords"
bboxin = unit_bbox()
ll = Point(Value(10), Value(10))
ur = Point(Value(200), Value(40))
bboxout = Bbox(ll, ur)

transform = get_bbox_transform(bboxin, bboxout)

assert (transform.xy_tup((0, 0)) == (10, 10))
assert (transform.xy_tup((1, 1)) == (200, 40))
assert (transform.xy_tup((0.5, 0.5)) == (105, 25))

# simulate a resize
ur.x().set(400)
ur.y().set(400)
assert (transform.xy_tup((0, 0)) == (10, 10))
assert (transform.xy_tup((1, 1)) == (400, 400))
assert (transform.xy_tup((0.5, 0.5)) == (205, 205))

pairs = (((0, 0), (10, 10)), ((1, 1), (400, 400)), ((0.5, 0.5), (205, 205)))

for p1, p2 in pairs:
Esempio n. 7
0
    ax = subplot(212)

    boxin = Bbox(
        Point(ax.viewLim.ll().x(), Value(-20)),
        Point(ax.viewLim.ur().x(), Value(20)))


    height = ax.bbox.ur().y() - ax.bbox.ll().y()
    boxout = Bbox(
        Point(ax.bbox.ll().x(), Value(-1)*height),
        Point(ax.bbox.ur().x(), Value(1) * height))


    transOffset = get_bbox_transform(
        unit_bbox(),
        Bbox( Point( Value(0), ax.bbox.ll().y()),
              Point( Value(1), ax.bbox.ur().y())
              ))


    for i in range(numRows):
        # effectively a copy of transData
        trans = get_bbox_transform(boxin, boxout) 
        offset = (i+1)/(numRows+1)

        trans.set_offset( (0, offset), transOffset)
        
        thisLine = Line2D(
            t, data[:,i]-data[0,i],
            )
        
Esempio n. 8
0
    t = arange(numSamples) / float(numSamples) * 10.0
    ticklocs = []
    ax = subplot(212)

    boxin = Bbox(Point(ax.viewLim.ll().x(), Value(-20)),
                 Point(ax.viewLim.ur().x(), Value(20)))

    height = ax.bbox.ur().y() - ax.bbox.ll().y()
    boxout = Bbox(Point(ax.bbox.ll().x(),
                        Value(-1) * height),
                  Point(ax.bbox.ur().x(),
                        Value(1) * height))

    transOffset = get_bbox_transform(
        unit_bbox(),
        Bbox(Point(Value(0),
                   ax.bbox.ll().y()), Point(Value(1),
                                            ax.bbox.ur().y())))

    for i in range(numRows):
        # effectively a copy of transData
        trans = get_bbox_transform(boxin, boxout)
        offset = (i + 1) / (numRows + 1)

        trans.set_offset((0, offset), transOffset)

        thisLine = Line2D(
            t,
            data[:, i] - data[0, i],
        )