示例#1
0
文件: plot.py 项目: trmrsh/trm-dnl
def psetupa():
    """After-device open setup"""
    """Pre-device open setup"""
    if PLPLOT:
        plg.plwidth(2)
    else:
        plg.pgscf(2)
        plg.pgslw(2)
示例#2
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()
示例#3
0
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")
示例#4
0
文件: plot.py 项目: trmrsh/trm-dnl
def plwidth(width):
    if PLPLOT:
        plg.plwidth(col)
    else:
        plg.pgslw(width)