Exemplo n.º 1
0
    def SetPoints(self, points):
        """ SetPoints(points)
        
        Set x,y (and optionally z) data. The given argument can be anything
        that can be converted to a pointset. (From version 1.7 this method
        also works with 2D pointsets.)
        
        The data is copied, so changes to original data will not affect
        the visualized points. If you do want this, use the points property.
        
        """

        # Try make it a (copied) pointset (handle masked array)
        if is_Pointset(points):
            points = Pointset(handleInvalidValues(points.data))
        else:
            points = Pointset(handleInvalidValues(points))

        # Add z dimension to points if not available
        if points.ndim == 3:
            pass
        elif points.ndim == 2:
            zz = 0.1 * np.ones((len(points._data), 1), dtype='float32')
            points._data = np.concatenate((points._data, zz), 1)
        elif points.ndim == 1:
            N = len(points._data)
            xx = np.arange(N, dtype='float32').reshape(N, 1)
            zz = 0.1 * np.ones((N, 1), dtype='float32')
            points._data = np.concatenate((xx, points._data, zz), 1)

        # Store
        self._points = points
Exemplo n.º 2
0
 def SetPoints(self, points):
     """ SetPoints(points)
     
     Set x,y (and optionally z) data. The given argument can be anything
     that can be converted to a pointset. (From version 1.7 this method
     also works with 2D pointsets.)
     
     The data is copied, so changes to original data will not affect 
     the visualized points. If you do want this, use the points property.
     
     """
     
     # Try make it a (copied) pointset (handle masked array)
     if is_Pointset(points):
         points = Pointset(handleInvalidValues(points.data))
     else:
         points = Pointset(handleInvalidValues(points))
    
     # Add z dimension to points if not available
     if points.ndim == 3:
         pass
     elif points.ndim == 2:
         zz = 0.1*np.ones((len(points._data),1), dtype='float32')
         points._data = np.concatenate((points._data, zz),1)
     elif points.ndim == 1:
         N = len(points._data)
         xx = np.arange(N, dtype='float32').reshape(N, 1)
         zz = 0.1*np.ones((N,1), dtype='float32')
         points._data = np.concatenate((xx, points._data, zz), 1)
     
     # Store
     self._points = points