コード例 #1
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()
コード例 #2
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()
コード例 #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()
コード例 #4
0
    def plotHistogram(self):

        def plfbox(x0, y0):
            x = numpy.array([x0, x0, x0 + 1.0, x0 + 1.0])
            y = numpy.array([0.0, y0, y0, 0.0])
            plplot.plfill(x, y)
            plplot.plcol0(1)
            plplot.pllsty(1)
            plplot.plline(x, y)

        self.plot.clearWidget();

        y0 = numpy.array([5, 15, 12, 24, 28, 30, 20, 8, 12, 3])
        pos = numpy.array([0.0, 0.25, 0.5, 0.75, 1.0])
        red = numpy.array([0.0, 0.25, 0.5, 1.0, 1.0])
        green = numpy.array([1.0, 0.5, 0.5, 0.5, 1.0])
        blue = numpy.array([1.0, 1.0, 0.5, 0.25, 0.0])

	plplot.pladv(0)
	plplot.plvsta()
	
	plplot.plcol0(2)
	
	plplot.plwind(1980.0, 1990.0, 0.0, 35.0)
	plplot.plbox("bc", 1.0, 0, "bcnv", 10.0, 0)
	plplot.plcol0(2)
	plplot.pllab("Year", "Widget Sales (millions)", "#frPLplot Example 12")

 	plplot.plscmap1l(1,pos,red,green,blue)

	for i in range(10):
            plplot.plcol1(i/9.0)
            plplot.plpsty(0)
            plfbox((1980. + i), y0[i])
            string = "%.0f" % (y0[i])
            plplot.plptex((1980. + i + .5), (y0[i] + 1.), 1.0, 0.0, .5, string)
            string = "%d" % (1980 + i)
            plplot.plmtex("b", 1.0, ((i + 1) * .1 - .05), 0.5, string)
       
        self.update()
コード例 #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()
コード例 #6
0
This is the original code used to develop the plplot renderer module
"""

# set up some data to plot
from Numeric import *

x = arange(10, typecode=Float)
y = x**2

import plplot

plplot.plsdev("xwin")
plplot.plinit()
plplot.plenv(min(x), max(x), min(y), max(y), 0, 1)
plplot.pllab("x", "x**2", "Example 2D plot")
plplot.plline(x, y)
plplot.plend()

# to save as well, have to set everything up again, and replot
# save as png
plplot.plsdev("png")
plplot.plsfnam("simplePlotExample.png")
plplot.plinit()
plplot.plenv(min(x), max(x), min(y), max(y), 0, 1)
plplot.pllab("x", "x**2", "Example 2D plot")
plplot.plline(x, y)
plplot.plend()

# save as postscript
plplot.plsdev("psc")
コード例 #7
0
ファイル: plot.py プロジェクト: trmrsh/trm-dnl
def pllab(xlabel, ylabel, tlabel):
    if PLPLOT:
        plg.pllab(xlabel, ylabel, tlabel)
    else:
        plg.pglab(xlabel, ylabel, tlabel)
コード例 #8
0
ファイル: contourPlot.py プロジェクト: paultcochrane/pyvisi
    for j in range(len(y)):
	z[i,j] = x[i]*exp(-x[i]*x[i] - y[j]*y[j])

import plplot

# determine the min and max of x
xMin = min(x)
xMax = max(x)

yMin = min(y)
yMax = max(y)

plplot.plsdev("xwin")
plplot.plinit()
plplot.plenv(xMin, xMax, yMin, yMax, 0, 1)
plplot.pllab("x", "y", "Example shaded contour plot")
plshades(zz, shedge, fill_width, 1, pltr1, xg1, yg1)

zmin = min(zz.flat)
zmax = max(zz.flat)

clevel = zmin + (zmax - zmin) * (arrayrange(NS)+0.5)/NS
shedge = zmin + (zmax - zmin) * (arrayrange(NS+1))/NS

plplot.plend()

# to save as well, have to set everything up again, and replot
# save as png
plplot.plsdev("png")
plplot.plsfnam("contourPlot.png")
plplot.plinit()
コード例 #9
0
import plplot

# determine the min and max of x
xMin = min(x)
xMax = max(x)

# determine the global min and max of all the y's
yAll = concatenate( [y1, y2, y3] )

yMin = min(yAll)
yMax = max(yAll)

plplot.plsdev("xwin")
plplot.plinit()
plplot.plenv(xMin, xMax, yMin, yMax, 0, 1)
plplot.pllab("x", "y", "Example 2D plot")
plplot.plline(x, y1)
plplot.plline(x, y2)
plplot.plline(x, y3)
plplot.plend()

# to save as well, have to set everything up again, and replot
# save as png
plplot.plsdev("png")
plplot.plsfnam("multiCurveLinePlot.png")
plplot.plinit()
plplot.plenv(xMin, xMax, yMin, yMax, 0, 1)
plplot.pllab("x", "y", "Example 2D plot")
plplot.plline(x, y1)
plplot.plline(x, y2)
plplot.plline(x, y3)