Example of plotting lines with pyvisi 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
# sides of box in normalised coordinates # (these are values recommended by plplot in an example) basex = 2.0 basey = 4.0 height = 3.0 # angle to view box alt = 45.0 az = 30.0 side = 1 opt = 3 # plots a net of lines plplot.plsdev("xwin") plplot.plinit() plplot.plenv(xMin2D, xMax2D, yMin2D, yMax2D, 0, -2) plplot.plw3d(basex, basey, height, xMin, xMax, yMin, yMax, zMin, zMax, alt, az) plplot.plmtex("t", 1.0, 0.5, 0.5, "Example surface plot") plplot.plbox3("bnstu", "x axis", 0.0, 0, "bnstu", "y axis", 0.0, 0, "bcdmnstuv", "z axis", 0.0, 0) plplot.plsurf3d(x, y, z, 0, ()) plplot.plend() # to save as well, have to set everything up again, and replot # save as png plplot.plsdev("png") plplot.plsfnam("surfacePlot.png") plplot.plinit()
def plenv(x1, x2, y1, y2, just, axis): if PLPLOT: plg.plenv(x1,x2,y1,y2,just,axis) else: plg.pgenv(x1,x2,y1,y2,just,axis)
for i in range(len(x)): 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")