121121 xy_tup(xy) - transform the tuple (x,y)
122122 seq_x_y(x, y) - transform the python sequences x and y
123123 numerix_x_y(x, y) - x and y are numerix 1D arrays
124- seq_xy_tups(seq) - seq is a sequence of xy tuples
124+ numerix_xy(xy) - xy is a numerix array of shape (N,2)
125+ inverse_numerix_xy(xy)- inverse of the above
126+ seq_xy_tups(seq) - seq is a sequence of xy tuples or a (N,2) array
125127 inverse_xy_tup(xy) - apply the inverse transformation to tuple xy
126128
127129 set_offset(xy, trans) - xy is an x,y tuple and trans is a
141143 set_funcx() - set the Func instance on x
142144 set_funcy() - set the Func instance on y
143145
146+
144147Affine transformations
145148----------------------
146149
@@ -423,9 +426,11 @@ def inverse_transform_bbox(trans, bbox):
423426 return Bbox (Point (Value (xmin ), Value (ymin )),
424427 Point (Value (xmax ), Value (ymax )))
425428
429+ ## begin possibly deleted block; all transforms have deepcopy
430+ ## and shallowcopy methods, we may not need any of the following
426431
427- def copy_bbox_transform (trans ):
428- 'return a deep copy of the bbox transform'
432+ def copy_separable_transform (trans ):
433+ 'return a deep copy of the separable transform'
429434
430435 inbox = trans .get_bbox1 ()
431436 xmin , xmax = inbox .intervalx ().get_bounds ()
@@ -436,7 +441,7 @@ def copy_bbox_transform(trans):
436441 outbox = trans .get_bbox2 ()
437442 xmin , xmax = outbox .intervalx ().get_bounds ()
438443 ymin , ymax = outbox .intervaly ().get_bounds ()
439-
444+
440445 newOutbox = Bbox ( Point (Value (xmin ), Value (ymin )),
441446 Point (Value (xmax ), Value (ymax )) )
442447
@@ -449,10 +454,12 @@ def copy_bbox_transform(trans):
449454 newtrans .get_funcy ().set_type (typey )
450455 return newtrans
451456
457+ copy_bbox_transform = copy_separable_transform
458+
452459
453- def copy_bbox_transform_shallow (trans ):
460+ def copy_separable_transform_shallow (trans ):
454461 """
455- return a shallow copy of the bbox transform -- the Values are
462+ return a shallow copy of the separable transform -- the Values are
456463 retained by reference but the transform is copied. This allows
457464 you to copy a transform, set a new offset to it, but not lose the
458465 value reference semantics
@@ -470,6 +477,37 @@ def copy_bbox_transform_shallow(trans):
470477 newtrans .get_funcy ().set_type (typey )
471478 return newtrans
472479
480+ copy_bbox_transform_shallow = copy_separable_transform_shallow
481+
482+ def copy_transform_shallow (trans ):
483+ return trans .shallowcopy ()
484+
485+ ## end possibly deleted block
486+
487+ def offset_copy (trans , fig = None , x = 0 , y = 0 , units = 'inches' ):
488+ '''
489+ Return a shallow copy of a transform with an added offset.
490+ args:
491+ trans is any transform
492+ kwargs:
493+ fig is the current figure; it can be None if units are 'dots'
494+ x, y give the offset in units of 'inches' or 'dots'
495+ units is 'inches' or 'dots'
496+ '''
497+ newtrans = trans .shallowcopy ()
498+ if units == 'dots' :
499+ newtrans .set_offset ((x ,y ), identity_transform ())
500+ return newtrans
501+ if not units == 'inches' :
502+ raise ValueError ('units must be dots or inches' )
503+ if fig is None :
504+ raise ValueError ('For units of inches a fig kwarg is needed' )
505+ tx = Value (x ) * fig .dpi
506+ ty = Value (y ) * fig .dpi
507+ newtrans .set_offset ((0 ,0 ), translation_transform (tx , ty ))
508+ return newtrans
509+
510+
473511def get_vec6_scales (v ):
474512 'v is an affine vec6 a,b,c,d,tx,ty; return sx, sy'
475513 a ,b ,c ,d = v [:4 ]
0 commit comments