Beispiel #1
0
def plot2(w):

    # Set up the viewport and window using w.plenv. The range in X
    # is -2.0 to 10.0, and the range in Y is -0.4 to 2.0. The axes
    # are scaled separately (just = 0), and we draw a box with
    # axes (axis = 1).

    w.plcol0(1)
    w.plenv(-2.0, 10.0, -0.4, 1.2, 0, 1)
    w.plcol0(2)
    w.pllab("(x)", "sin(x)/x", "#frPLplot Example 1 - Sinc Function")

    # Fill up the arrays

    x = (arange(100) - 19) / 6.0
    if 0.0 in x:
        #replace 0.0 by small value that gives the same sinc(x) result.
        x[list(x).index(0.0)] = 1.e-30
    y = sin(x) / x

    # Draw the line

    w.plcol0(3)
    w.plline(x, y)
    w.plflush()
Beispiel #2
0
def plot3(w):

    # For the final graph we wish to override the default tick
    # intervals, so do not use w.plenv

    w.pladv(0)

    # Use standard viewport, and define X range from 0 to 360
    # degrees, Y range from -1.2 to 1.2.

    w.plvsta()
    w.plwind(0.0, 360.0, -1.2, 1.2)

    # Draw a box with ticks spaced 60 degrees apart in X, and 0.2 in Y.

    w.plcol0(1)
    w.plbox("bcnst", 60.0, 2, "bcnstv", 0.2, 2)

    # Superimpose a dashed line grid, with 1.5 mm marks and spaces.

    w.plstyl([1500], [1500])
    w.plcol0(2)
    w.plbox("g", 30.0, 0, "g", 0.2, 0)
    w.plstyl([], [])

    w.plcol0(3)
    w.pllab("Angle (degrees)", "sine", "#frPLplot Example 1 - Sine function")

    x = 3.6 * arange(101)
    y = sin((pi / 180.) * x)

    w.plcol0(4)
    w.plline(x, y)
    w.plflush()
Beispiel #3
0
def plot1(w, xscale, yscale, xoff, yoff):

    x = xoff + (xscale / 60.) * (1 + arange(60))
    y = yoff + yscale * pow(x, 2.)

    xmin = x[0]
    xmax = x[59]
    ymin = y[0]
    ymax = y[59]

    xs = x[3::10]
    ys = y[3::10]

    # Set up the viewport and window using w.plenv. The range in X
    # is 0.0 to 6.0, and the range in Y is 0.0 to 30.0. The axes
    # are scaled separately (just = 0), and we just draw a
    # labelled box (axis = 0).

    w.plcol0(1)
    w.plenv(xmin, xmax, ymin, ymax, 0, 0)
    w.plcol0(6)
    w.pllab("(x)", "(y)", "#frPLplot Example 1 - y=x#u2")

    # Plot the data points

    w.plcol0(9)
    w.plpoin(xs, ys, 9)

    # Draw the line through the data

    w.plcol0(4)
    w.plline(x, y)
    w.plflush()
Beispiel #4
0
def plot4(w):

    dtr = pi / 180.0
    x0 = cos(dtr * arange(361))
    y0 = sin(dtr * arange(361))

    # Set up viewport and window, but do not draw box

    w.plenv(-1.3, 1.3, -1.3, 1.3, 1, -2)

    i = 0.1 * arange(1, 11)
    #outerproduct(i,x0) and outerproduct(i,y0) is what we are
    #mocking up here since old Numeric version does not have outerproduct.
    i.shape = (-1, 1)
    x = i * x0
    y = i * y0

    # Draw circles for polar grid
    for i in range(10):
        w.plline(x[i], y[i])

    w.plcol0(2)
    for i in range(12):
        theta = 30.0 * i
        dx = cos(dtr * theta)
        dy = sin(dtr * theta)

        # Draw radial spokes for polar grid

        w.pljoin(0.0, 0.0, dx, dy)

        # Write labels for angle

        text = ` int(theta) `
        #Slightly off zero to avoid floating point logic flips at 90 and 270 deg.
        if dx >= -0.00001:
            w.plptex(dx, dy, dx, dy, -0.15, text)
        else:
            w.plptex(dx, dy, -dx, -dy, 1.15, text)

    # Draw the graph

    r = sin((dtr * 5.) * arange(361))
    x = x0 * r
    y = y0 * r

    w.plcol0(3)
    w.plline(x, y)

    w.plcol0(4)
    w.plmtex("t", 2.0, 0.5, 0.5, "#frPLplot Example 3 - r(#gh)=sin 5#gh")
    w.plflush()
Beispiel #5
0
def plot5(w):

    mark = 1500
    space = 1500

    clevel = -1. + 0.2 * arange(11)

    xx = (arange(XPTS) - XPTS / 2) / float((XPTS / 2))
    yy = (arange(YPTS) - YPTS / 2) / float((YPTS / 2)) - 1.
    xx.shape = (-1, 1)
    z = (xx * xx) - (yy * yy)
    # 2.*outerproduct(xx,yy) for new versions of Numeric which have outerproduct.
    w_array = 2. * xx * yy

    w.plenv(-1.0, 1.0, -1.0, 1.0, 0, 0)
    w.plcol0(2)
    w.plcont(z, clevel, mypltr, tr)
    w.plstyl([mark], [space])
    w.plcol0(3)
    w.plcont(w_array, clevel, mypltr, tr)
    w.plstyl([], [])
    w.plcol0(1)
    w.pllab("X Coordinate", "Y Coordinate", "Streamlines of flow")
    w.plflush()