@@ -224,6 +224,7 @@ class Bbox(BboxBase):
224224 def __init__ (self , points ):
225225 BboxBase .__init__ (self )
226226 self ._points = npy .asarray (points , npy .float_ )
227+ self ._minpos = npy .array ([0.0000001 , 0.0000001 ])
227228 self ._invalid = False
228229
229230 #@staticmethod
@@ -252,15 +253,22 @@ def _do_invalidation(self, affine_only):
252253 return result
253254
254255 def update_from_data (self , x , y , ignore = True ):
255- if ignore :
256- self ._points = npy .array (
257- [[x .min (), y .min ()], [x .max (), y .max ()]],
258- npy .float_ )
259- else :
256+ if ignore :
257+ self ._points = npy .array (
258+ [[x .min (), y .min ()], [x .max (), y .max ()]],
259+ npy .float_ )
260+ self ._minpos = npy .array (
261+ [npy .where (x > 0.0 , x , npy .inf ).min (), npy .where (y > 0.0 , y , npy .inf ).min ()],
262+ npy .float_ )
263+ else :
260264 self ._points = npy .array (
261265 [[min (x .min (), self .xmin ), min (y .min (), self .ymin )],
262266 [max (x .max (), self .xmax ), max (y .max (), self .ymax )]],
263267 npy .float_ )
268+ minpos = npy .array (
269+ [npy .where (x > 0.0 , x , npy .inf ).min (), npy .where (y > 0.0 , y , npy .inf ).min ()],
270+ npy .float_ )
271+ self ._minpos = npy .minimum (minpos , self ._minpos )
264272 self .invalidate ()
265273
266274 def _set_xmin (self , val ):
@@ -309,6 +317,18 @@ def _set_bounds(self, bounds):
309317 self .invalidate ()
310318 bounds = property (BboxBase ._get_bounds , _set_bounds )
311319
320+ def _get_minpos (self ):
321+ return self ._minpos
322+ minpos = property (_get_minpos )
323+
324+ def _get_minposx (self ):
325+ return self ._minpos [0 ]
326+ minposx = property (_get_minposx )
327+
328+ def _get_minposy (self ):
329+ return self ._minpos [1 ]
330+ minposy = property (_get_minposy )
331+
312332 def get_points (self ):
313333 self ._invalid = False
314334 return self ._points
@@ -541,7 +561,7 @@ def transform(self, values):
541561# print "".join(traceback.format_stack())
542562# print points
543563 mtx = self .get_matrix ()
544- points = npy .asarray (values , npy .float_ )
564+ # points = npy.asarray(values, npy.float_)
545565 return points * mtx [0 ,0 ] + mtx [0 ,1 ]
546566
547567 transform_affine = transform
@@ -695,10 +715,15 @@ def transform(self, points):
695715# print "".join(traceback.format_stack())
696716# print points
697717 mtx = self .get_matrix ()
698- points = npy .asarray (points , npy .float_ )
699- points = points .transpose ()
700- points = npy .dot (mtx [0 :2 , 0 :2 ], points )
701- points = points + mtx [0 :2 , 2 :]
718+ if ma .isarray (points ):
719+ points = points .transpose ()
720+ points = ma .dot (mtx [0 :2 , 0 :2 ], points )
721+ points = points + mtx [0 :2 , 2 :]
722+ else :
723+ points = npy .asarray (points , npy .float_ )
724+ points = points .transpose ()
725+ points = npy .dot (mtx [0 :2 , 0 :2 ], points )
726+ points = points + mtx [0 :2 , 2 :]
702727 return points .transpose ()
703728
704729 transform_affine = transform
@@ -869,7 +894,7 @@ def transform(self, points):
869894 y_points = y .transform (points [:, 1 ])
870895 y_points = y_points .reshape ((len (y_points ), 1 ))
871896
872- return npy .concatenate ((x_points , y_points ), 1 )
897+ return ma .concatenate ((x_points , y_points ), 1 )
873898 transform_non_affine = transform
874899
875900 def transform_affine (self , points ):
0 commit comments