Hi,

As promised, here's a short patch to add get_offsets() and set_offsets() to the Collections() base class. I tried to make it do the right thing with regard to _offsets vs. _uniform_offsets, depending on whether _uniform_offsets is None. I also had tried to make __init__ use set_offsets, but that proved to be too much of a hassle for too little code reuse.

Comments?

Ryan

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
--- collections.py	(revision 5792)
+++ collections.py	(working copy)
@@ -222,6 +222,32 @@
     def set_pickradius(self,pickradius): self.pickradius = 5
     def get_pickradius(self): return self.pickradius
 
+    def set_offsets(self, offsets):
+        """
+        Set the offsets for the collection.  *offsets* can be a scalar
+        or a sequence.
+        
+        ACCEPTS: float or sequence of floats
+        """
+        offsets = np.asarray(offsets, np.float_)
+        if len(offsets.shape) == 1:
+            offsets = offsets[np.newaxis,:]  # Make it Nx2.
+        #This decision is based on how they are initialized above
+        if self._uniform_offsets is None:
+            self._offsets = offsets
+        else:
+            self._uniform_offsets = offsets
+
+    def get_offsets(self):
+        """
+        Return the offsets for the collection.
+        """
+        #This decision is based on how they are initialized above in __init__()
+        if self._uniform_offsets is None:
+            return self._offsets
+        else:
+            return self._uniform_offsets
+
     def set_linewidths(self, lw):
         """
         Set the linewidth(s) for the collection.  *lw* can be a scalar

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to