예제 #1
0
 def set_axes(self):
     Plot3D.set_axes(self)
     xlist = Num.arange(self.xstart, self.xstop+1, self.xstep)
     ylist = Num.arange(self.ystart, self.ystop+1, self.ystep)
     zlist = utilities.zcalculator(self.function, xlist, ylist)
     ai = auto_axes3D(xlist, ylist, zlist, axes = self.axes)
     self.axes(focustype = 'user', focuspoint = ai.focus)
예제 #2
0
파일: demos.py 프로젝트: pmagwene/disipyl
def colorPlot3DDemo(ret=None):
    """Demonstrates 3-D color plot.
    
    Comments:
    """
    if not hasnumeric:
        print "demos.colorPlot3DDemo requires numpy"
        return None

    title = "Demonstration of 3-D Color Plot \n\n" +\
            "$f(x,y)=cos(x)sin(y)$"

    def f(x,y):
        return math.cos(x*math.pi/180) * math.sin(y*math.pi/180)
        
    # generate data
    x = range(0, 360, 3)
    y = range(0, 360, 3)
    zlist = utilities.zcalculator(f,x,y)
    zmatrix = Num.reshape(zlist, (len(x), len(y)))

    # setup plot        
    plot = contours.ColorPlot()
    plot.title = pxdislin.Title(text = title)
    
    plot.axes(lengths = (2200,1400,1400),
              pageposition = (300,1850),
              autoresolution = (len(x), len(y)) )
    plot.axes.xaxis(min = 0, 
                    max = 360, 
                    tickstart = 0, 
                    tickstep = 90, 
                    name = 'X-Axis')
    plot.axes.yaxis(min = 0, 
                    max = 360, 
                    tickstart = 0, 
                    tickstep = 90, 
                    name = 'Y-Axis')
    plot.axes.zaxis(min = -1, 
                    max = 1, 
                    tickstart = -1, 
                    tickstep = 0.5, 
                    name = 'Z-Axis')
    
    # Create 3-D color representation of a matrix or list
    nr, nc = zmatrix.shape
    colormatrix = contours.ColorMatrix(zmatrix, nr, nc)
    plot.add(colormatrix)
        
    canvas = pxdislin.Canvas(plot)
    if ret:
        return canvas
    else:
        canvas.draw()
예제 #3
0
파일: demos.py 프로젝트: pmagwene/disipyl
def colorDemo(ret=None,colortable='rainbow'):
    """Generates a color bar showing values of color indices."""
    if not hasnumeric:
        print "demos.colorDemo requires Numeric"
        return None
    
    def f(x,y):
        return x
        
    # data
    x = range(0, 256)
    y = range(0, 2)
    zlist = utilities.zcalculator(f,x,y)
    zmatrix = Num.reshape(zlist, (len(x), len(y)))
    
    # plot
    plot = contours.ColorPlot()

    plot.axes(autoresolution = (len(x), len(y)),
              axisparts=('all','none','none','none'), 
              suppresscolorbar=1,
              lengths = (2000,500,500),
              pageposition = (150,650),
              integerlabels = 1)    
    plot.axes.xaxis(min = 0, 
                    max = 255, 
                    tickstart = 0,
                    tickstep = 50, 
                    name = 'Color Index')
    plot.axes.yaxis(min = 0,
                    max = 1, 
                    tickstart = 0, 
                    tickstep = 0.5)
    plot.axes.zaxis(min = 0, 
                    max = 255, 
                    tickstart = 0, 
                    tickstep = 25)


    
    # Create 3-D color representation of a matrix or list
    nr, nc = zmatrix.shape
    colormatrix = contours.ColorMatrix(zmatrix, nr, nc)
    plot.add(colormatrix)
       
    canvas = pxdislin.Canvas(plot, colortable=colortable)
    canvas.page(width = 2400, height = 1000, scalingmode='full')

    if ret:
        return canvas
    else:
        canvas.draw()
예제 #4
0
파일: demos.py 프로젝트: pmagwene/disipyl
def surfaceDemo(ret=None):
    """Shows of the IrregularSurface and ShadedSurface Plots."""
    
    title1 = "Plot created with IrregularSurface Object \n\n"+\
             " $f(x,y) = x^2 - y^2$"

    title2 = "Plot created with ShadedSurface Object \n\n"+\
             " $f(x,y) = x^2 - y^2$"    
    
    # setup data
    def f(x,y): return x**2 - y**2
    xlist = Num.arange(-1,1,0.1)
    ylist = Num.arange(-1,1,0.1)
    zlist = utilities.zcalculator(f, xlist, ylist)
    
    # setup plots         
    plot1 = plots.Plot3D()
    plot1.title = pxdislin.Title(text = title1, offset = -400)
    plot1.axes(pagesize = (2000,2000))    
    irsurf = pxdislin3D.IrregularSurface(xlist, ylist, zlist)
    plot1.add(irsurf)
    
    plot2 = plots.Plot3D()
    plot2.title = pxdislin.Title(text = title2, offset = -200)
    plot2.axes(pagesize = (2000,2000), centered = 1)
    shdsurf = pxdislin3D.ShadedSurface(xlist, ylist, zlist)
    plot2.add(shdsurf)
    # we're gonna draw this one at a different angle
    plot2.rotate_left(12)
    plot2.rotate_down(10)  
        
    canvas = pxdislin.Canvas(plot2, screenmode='black')
    canvas.page(width = 3000, height = 3000)    

    # I need to figure out why DISLIN doesn't like a 2UP Canvas with
    # an Irregular surface object (calling draw causes crash)    
    canvas2 = pxdislin.Canvas2UP(plot1, plot2)
    canvas2.page(width = 6000, height = 3000)
    
    if ret:
        return canvas
    else:
        canvas.draw()
예제 #5
0
파일: demos.py 프로젝트: pmagwene/disipyl
def contourDemo2(ret=None):
    """Demonstrates use of Contour objects, ShadedContours, and the Canvas2UP object.
    
    Comments:   
    * Use of individual Contour ojects rather than a FunctionContours 
       object allows for a greater amount of tweaking.  
    * I use a Loop object (from disipyl.utilies) for cycling attributes.
    * I generate two contour plots of the same function, one using standard
       Contours, and one using a ShadedContours object.
    """
    
    title = "Demonstration of Contours\n\n" +\
            "$f(x,y) = (x^2-1)^2 + (y^2-1)^2$"

    def f(x,y):
        return (x**2 - 1)**2 + (y**2 - 1)**2
        
    # generate data
    xlist = Num.arange(0, 1.6, 0.03)
    ylist = Num.arange(0, 1.6, 0.03)
    zlist = utilities.zcalculator(f, xlist, ylist)
    levels = Num.arange(1.3, 0, -0.1)
    
    # setup the first plot    
    plot1 = plots.Plot2D()
    plot1.title = pxdislin.Title(text = title)
    
    plot1.axes(pagesize = (1200,2200))
    plot1.axes.xaxis(min = 0,
                     max = 1.6, 
                     tickstart = 0, 
                     tickstep = 0.2, 
                     name = 'X-Axis')
    plot1.axes.yaxis(min = 0, 
                     max = 1.6,
                     tickstart = 0, 
                     tickstep = 0.2, 
                     name = 'Y-Axis')
    
    # generate contours, with repeating line types (see disipyl.utilties)
    stylecycle = utilities.Loop(['dot','dash','solid'])
    widthcycle = utilities.Loop([1,1,3])
    cntrs = []
    for i in range(12):
        cntr = contours.Contour(xlist, ylist, zlist, levels[i])
        cntr(linestyle = stylecycle[i], linewidth = widthcycle[i])
        cntrs.append(cntr)
                                                
    plot1.add(*cntrs)       # note how I add a sequence of contours, a single contour
                            # would be added as plot.add(contour)
                            # you could also do this as [plot1.add(c) for c in contours]

    
    # setup the second plot                    
    plot2 = plots.Plot2D()
    plot2.title = pxdislin.Title(text = title)
    
    plot2.axes(pagesize = (1200,2200))
    plot2.axes.xaxis(min = 0, 
                     max = 1.6, 
                     tickstart = 0, 
                     tickstep = 0.2, 
                     name = 'X-Axis')
    plot2.axes.yaxis(min = 0,
                     max = 1.6, 
                     tickstart = 0, 
                     tickstep = 0.2, 
                     name = 'Y-Axis')
    
    shdcntrs = contours.ShadedContours(xlist, ylist, zlist, levels)
    shdcntrs(fillmode = 'polygon')
    plot2.add(shdcntrs)
         
    canvas = pxdislin.Canvas2UP(plot1,plot2)    # Note use of Canvas2UP
    canvas.page(width = 4500, height = 3500)    # change default page height

    if ret:
        return canvas
    else:
        canvas.draw()
 def setup_data(self):
     self.xlist = Num.arange(self.xstart, self.xstop, self.xstep)
     self.ylist = Num.arange(self.ystart, self.ystop, self.ystep)
     self.zlist = zcalculator(self.func, self.xlist, self.ylist)