Beispiel #1
0
    def draw_lines(self, gc, x, y):
        """
        x and y are equal length arrays, draw lines connecting each
        point in x, y
        """

        x = x.astype(nx.Int16)
        y = self.height * ones(y.shape, nx.Int16) - y.astype(nx.Int16)
        style = self._set_gd_style(gc)
        self.im.lines(zip(x, y), style)
        self.flush_clip()
Beispiel #2
0
    def draw_lines(self, gc, x, y):
        """
        x and y are equal length arrays, draw lines connecting each
        point in x, y
        """

        x = x.astype(nx.Int16)
        y = self.height*ones(y.shape, nx.Int16) - y.astype(nx.Int16)  
        style = self._set_gd_style(gc)
        self.im.lines( zip(x,y), style)
        self.flush_clip()
Beispiel #3
0
    def __draw_lines_hide(self, gc, x, y, transform=None):
        """
        x and y are equal length arrays, draw lines connecting each
        point in x, y
        """
        if debugPS: self._pswriter.write('% draw_lines \n')

        if transform:
            if transform.need_nonlinear():
                x, y, mask = transform.nonlinear_only_numerix(x,
                                                              y,
                                                              returnMask=1)
            else:
                mask = ones(x.shape)

        vec6 = transform.as_vec6_val()
        a, b, c, d, tx, ty = vec6
        sx, sy = get_vec6_scales(vec6)

        start = 0
        end = 1000
        points = zip(x, y)

        write = self._pswriter.write
        write('gsave\n')
        self.push_gc(gc)
        write('[%f %f %f %f %f %f] concat\n' % (a, b, c, d, tx, ty))

        while start < len(x):
            # put moveto on all the bad data and on the first good
            # point after the bad data
            codes = where(mask[start:end + 1], 'l', 'm')
            ind = nonzero(mask[start:end + 1] == 0) + 1
            if ind[-1] >= len(codes):
                ind = ind[:-1]
            put(codes, ind, 'm')

            thisx = x[start:end + 1]
            thisy = y[start:end + 1]
            to_draw = izip(thisx, thisy, codes)
            if not to_draw:
                break

            ps = ['%1.3f %1.3f m' % to_draw.next()[:2]]
            ps.extend(["%1.3f %1.3f %c" % tup for tup in to_draw])
            # we don't want to scale the line width, etc so invert the
            # scale for the stroke
            ps.append('\ngsave %f %f scale stroke grestore\n' %
                      (1. / sx, 1. / sy))
            write('\n'.join(ps))
            start = end
            end += 1000
        write("grestore\n")
Beispiel #4
0
    def __draw_lines_hide(self, gc, x, y, transform=None):
        """
        x and y are equal length arrays, draw lines connecting each
        point in x, y
        """
        if debugPS: self._pswriter.write('% draw_lines \n')
    
    
        if transform:
            if transform.need_nonlinear():
                x, y, mask = transform.nonlinear_only_numerix(x, y, returnMask=1)
            else:
                mask = ones(x.shape)

        vec6 = transform.as_vec6_val()
        a,b,c,d,tx,ty = vec6
        sx, sy = get_vec6_scales(vec6)

        start  = 0
        end    = 1000
        points = zip(x,y)

        write = self._pswriter.write
        write('gsave\n')
        self.push_gc(gc)
        write('[%f %f %f %f %f %f] concat\n'%(a,b,c,d,tx,ty))                
        
        while start < len(x):
            # put moveto on all the bad data and on the first good
            # point after the bad data
            codes = where(mask[start:end+1], 'l', 'm')
            ind = nonzero(mask[start:end+1]==0)+1
            if ind[-1]>=len(codes):
                ind = ind[:-1]
            put(codes, ind, 'm')
            
            thisx = x[start:end+1]
            thisy = y[start:end+1]
            to_draw = izip(thisx, thisy, codes)
            if not to_draw:
                break

            ps = ['%1.3f %1.3f m' % to_draw.next()[:2]]
            ps.extend(["%1.3f %1.3f %c" % tup for tup in to_draw])
            # we don't want to scale the line width, etc so invert the
            # scale for the stroke
            ps.append('\ngsave %f %f scale stroke grestore\n'%(1./sx,1./sy))
            write('\n'.join(ps))
            start = end
            end   += 1000
        write("grestore\n")
Beispiel #5
0
 def plot3d(self):
     # sample taken from http://www.scipy.org/Cookbook/Matplotlib/mplot3D
     ax3d = matplotlib.axes3d.Axes3D(self.fig)
     plt = self.fig.axes.append(ax3d)
     
     delta = nx.pi / 199.0
     u = nx.arange(0, 2*nx.pi+(delta*2), delta*2)
     v = nx.arange(0, nx.pi+delta, delta)
     
     x=nx.outerproduct(nx.cos(u),nx.sin(v))
     y=nx.outerproduct(nx.sin(u),nx.sin(v))
     z=nx.outerproduct(nx.ones(nx.size(u)), nx.cos(v))
     print x.shape, y.shape, z.shape
     
     #ax3d.plot_wireframe(x,y,z)
     surf = ax3d.plot_surface(x, y, z)
     surf.set_array(matplotlib.mlab.linspace(0, 1.0, len(v)))
     
     ax3d.set_xlabel('X')
     ax3d.set_ylabel('Y')
     ax3d.set_zlabel('Z')
     self.fig.savefig('globe')
Beispiel #6
0
    def plot3d(self):
        # sample taken from http://www.scipy.org/Cookbook/Matplotlib/mplot3D
        ax3d = matplotlib.axes3d.Axes3D(self.fig)
        plt = self.fig.axes.append(ax3d)

        delta = nx.pi / 199.0
        u = nx.arange(0, 2 * nx.pi + (delta * 2), delta * 2)
        v = nx.arange(0, nx.pi + delta, delta)

        x = nx.outerproduct(nx.cos(u), nx.sin(v))
        y = nx.outerproduct(nx.sin(u), nx.sin(v))
        z = nx.outerproduct(nx.ones(nx.size(u)), nx.cos(v))
        print x.shape, y.shape, z.shape

        #ax3d.plot_wireframe(x,y,z)
        surf = ax3d.plot_surface(x, y, z)
        surf.set_array(matplotlib.mlab.linspace(0, 1.0, len(v)))

        ax3d.set_xlabel('X')
        ax3d.set_ylabel('Y')
        ax3d.set_zlabel('Z')
        self.fig.savefig('globe')
Beispiel #7
0
    def draw_lines(self, gc, x, y):
        x = x.astype(nx.Int16)
        y = self.height * ones(y.shape, nx.Int16) - y.astype(nx.Int16)

        self.gdkDrawable.draw_lines(gc.gdkGC, zip(x, y))