Exemple #1
0
 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)
def main(w):
    w.pladv(0)
    w.plcol0(2)
    w.plvpor(0.02, 0.98, 0.02, 0.90)
    w.plwind(0.0, 1.0, 0.0, 1.0)
    w.plsfci(0)
    w.plschr(0., 2.5)
    # The text is Genesis, Chapter 1 verse 3 in Hebrew.
    w.plptex(0.5, 0.5, 1., 0., 0.5,
             "וַיֹּאמֶר אֱלֹהִים יְהִי אוֹר וַיְהִי אוֹר וַיַּרְא")
    w.plschr(0., 1.0)
    # Restore defaults
    w.plcol0(1)
def main(w):

    FCI_COMBINATIONS = 30
    w.plsfont(0, 0, 0)
    for index_fci in range(0, FCI_COMBINATIONS):
        family_index = index_fci % 5
        style_index = (index_fci / 5) % 3
        weight_index = ((index_fci / 5) / 3) % 2
        title = "Type 1 glyphs for family = " + family[
            family_index] + ", style = " + style[
                style_index] + ", weight = " + weight[weight_index]
        w.pladv(0)

        # Set up viewport and window

        w.plcol0(2)
        w.plvpor(0.1, 1.0, 0.1, 0.9)
        w.plwind(0.0, 1.0, 0.0, 1.0)

        # Draw the grid using w.plbox

        w.plbox("bcg", 1. / 16., 0, "bcg", 1. / 16., 0)

        # Write the digits below the frame

        w.plcol0(15)
        for i in range(16):
            w.plmtex("b", 1.5, ((i + 0.5) / 16.), 0.5, str(i))

        k = 0
        w.plmtex("t", 1.5, 0.5, 0.5, title)
        for i in range(16):

            # Write the digits to the left of the frame

            w.plmtex("lv", 1.0, (1.0 - (i + 0.5) / 16.), 1.0, str(16 * i))

            w.plsfont(family_index, style_index, weight_index)
            for j in range(16):
                x = (j + 0.5) / 16.
                y = 1. - (i + 0.5) / 16

                # Display the Type 1 glyph corresponding to k
                glyph_string = unichr(k).encode('utf-8')
                # Escape the escape.
                if glyph_string == "#":
                    glyph_string = "##"
                w.plptex(x, y, 1., 0., 0.5, glyph_string)
                k = k + 1
            w.plsfont(0, 0, 0)
Exemple #4
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()
Exemple #5
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()
Exemple #6
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()
Exemple #7
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()
Exemple #8
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()
Exemple #9
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()
Exemple #10
0
    def plotCurves(self):
        self.plot.clearWidget()

        # 1st plot
        indexes = numpy.arange(0, 360.1, 1.0)
        sine = numpy.sin(indexes * 3.14159 / 180.0)
        cosine = numpy.cos(indexes * 3.14159 / 180.0)

        plplot.pladv(0)
        plplot.plvpor(0.05, 0.95, 0.05, 0.45)
        plplot.plwind(0.0, 360.0, -1.2, 1.2)

	plplot.plcol0(2)
	plplot.plbox("bcnst", 0., 0, "bcnst", 0., 0)
	
	plplot.plcol0(1)
	plplot.plwidth(2)
	plplot.plline(indexes, sine)
	
	plplot.plcol0(3)
	plplot.plwidth(1)
	plplot.pllsty(2)
	plplot.plline(indexes, cosine)
	plplot.pllsty(1)

	plplot.plcol0(2)
	
	plplot.plmtex("t", 1., 0.5, 0.5, "Sines")

        # 2nd plot
        indexes = numpy.arange(-1.0, 1.0, 0.01)
        square = indexes * indexes
        cubic = square * indexes

	plplot.plvpor(0.05, 0.95, 0.55, 0.95)
	plplot.plwind(-1., 1., -1., 1.)
	
	plplot.plcol0(2)
	plplot.plbox("bcnst", 0., 0, "bcnst", 0., 0)
	
	plplot.plcol0(1)
	plplot.plwidth(2)
	plplot.plline(indexes, square)
	
	plplot.plcol0(3)
	plplot.plwidth(1)
	plplot.pllsty(2)
	plplot.plline(indexes, cubic)
	plplot.pllsty(1)
	
	plplot.plcol0(2)
	
	plplot.plmtex("t", 1., 0.5, 0.5, "Square & Cubic")

        self.update()
def main(w):

    x = (arange(XPTS) - (XPTS / 2)) / float(XPTS / 2)
    y = (arange(YPTS) - (YPTS / 2)) / float(YPTS / 2)
    x = 1.5*x
    y = 0.5 + y
    x.shape = (-1,1)
    r2 = (x*x) + (y*y)
    z = (1. - x)*(1. - x) + 100 * (x*x - y)*(x*x - y)
    # The log argument may be zero for just the right grid.  */
    z = log(choose(greater(z,0.), (exp(-5.), z)))

    x.shape = (-1,)
    zmin = min(z.flat)
    zmax = max(z.flat)
    nlevel = 10
    step = (zmax-zmin)/(nlevel+1)
    clevel = zmin + step + arange(nlevel)*step
    w.plschr(0., 1.8)
    w.plwidth(1)
    w.pladv(0)
    w.plvpor(0.0, 1.0, 0.0, 1.0)
    w.plwind(-0.43, 0.840, 0.05, 0.48)
    w.plcol0(1)
    w.plw3d(1.0, 1.0, 1.0, -1.5, 1.5, -0.5, 1.5, zmin, zmax,
          alt, az)
    w.plbox3("bnstu", "", 0.0, 0,
           "bnstu", "", 0.0, 0,
           "bcdmnstuv", "", 0.0, 0)
    # If converting the -dev svg result later with the ImageMagick
    # "convert" application or viewing the svg result with the ImageMagick
    # "display" application must compensate for the librsvg-2.22
    # positioning bug since librsvg is what ImageMagick uses
    # to interpret SVG results.
    if_rsvg_bug = True
    if if_rsvg_bug:
        shift = 1.00
    else:
        shift = 1.07
    w.plmtex3("zs", 5.0, shift, 1.0, "z axis")

    w.plcol0(2)
    # magnitude colored plot with faceted squares
    cmap1_init(w, 0)
    w.plsurf3d(x, y, z, w.MAG_COLOR | w.FACETED, ())

    # Shading to provide a good background for legend.
    x1 = 0.10
    x2 = 0.8
    w.plvpor(0.0, 1.0, 0.0, 1.0)
    w.plwind(0.0, 1.0, 0.0, 1.0)
    # Completely opaque from 0. to x1
    w.plscol0a(15, 0, 0, 0, 1.0)
    w.plcol0(15)
    x=array([0., 0., x1, x1])
    y=array([0., 1., 1., 0.])
    w.plfill(x,y)
    # Black transparent gradient.
    pos = array([0.0, 1.0])
    rcoord = array([0.0, 0.0])
    gcoord = array([0.0, 0.0])
    bcoord = array([0.0, 0.0])
    acoord = array([1.0, 0.0])
    rev = array([0, 0])
    w.plscmap1n(2)
    w.plscmap1la(1, pos, rcoord, gcoord, bcoord, acoord, rev)
    x=array([x1, x1, x2, x2])
    w.plgradient(x,y,0.)
    # Logo Legend
    w.plscol0a(15, 255, 255, 255, 1.0)
    w.plcol0(15)
    x1 = 0.03
    w.plschr(0., 2.9)
    w.plsfont(w.PL_FCI_SANS, w.PL_FCI_UPRIGHT, w.PL_FCI_BOLD)
    w.plptex(x1, 0.57, 1.0, 0.0, 0.0, "PLplot")
    w.plschr(0., 1.5)
    w.plptex(x1, 0.30, 1.0, 0.0, 0.0,
           "The ultimate in cross-platform plotting")
Exemple #12
0
#!/usr/bin/env python

# Append to effective python path so that can find plplot modules.
from plplot_python_start import *

import sys
import plplot as w
from numpy import *

# Parse and process command line arguments
w.plparseopts(sys.argv, w.PL_PARSE_FULL)

# Initialize plplot
w.plinit()
# Like yellow lines better.
w.plcol0(2)
w.pladv(0)
w.plvpor(0.1, 0.9, 0.1, 0.9)
w.plwind(0., 1., 0., 1.)
x=0.*arange(2)
y=1.*arange(2)
w.plline(x,y)
x=0.1*arange(2)
y=0.5+0.*arange(2)
w.plline(x,y)
w.plschr(0., 4.)
#w.plmtex("l", 0., 0.5, 0.5, "#[0x00d7]#[0x00d7]#[0x00d7]#[0x00d7]#[0x00d7]#[0x00d7]#[0x00d7]")
w.plmtex("l", 0., 0.5, 0.5, "HHHHHHH")

# Terminate plplot
w.plend()
Exemple #13
0
def plcol0(col):
    if PLPLOT:
        plg.plcol0(col)
    else:
        plg.pgsci(col)
# -*- coding: utf-8; -*-
# Test whether utf8 and PLplot #[0x...] unicode encoding give same result.
# Also test whether #<FCI-COMMAND-STRING/> form works to change font
# characteristics on the fly.
# Append to effective python path so that can find plplot modules.
from plplot_python_start import *

import sys
import plplot as w
from numpy import *

# Parse and process command line arguments
w.plparseopts(sys.argv, w.PL_PARSE_FULL)

# Initialize plplot
w.plinit()
w.plcol0(2)
w.pladv(0)
w.plvpor(0.1, 0.9, 0.1, 0.9)
w.plwind(0., 1., 0., 1.)
# Just to show edges of viewport
w.plbox("bc", 0., 0, "bc", 0., 0)
w.plcol0(1)
w.plschr(0., 2.)
w.plptex(0.5, 0.5, 1., 0., 0.5, "#<sans-serif/>#[0x222e] is a path integral sign.")
# semitransparent green.
w.plscol0a(2, 0, 255, 0, 0.5)
w.plcol0(2)
w.plptex(0.5, 0.5, 1., 0., 0.5, "#<sans-serif/>∮ is a path integral sign.")
w.plend()