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 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()
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()
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)
# 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()
w.plbox("bc", 0., 0, "bc", 0., 0) w.plptex(0.5, 0.8, 1., 0., 0.5, "X#d0#d#<italic/>1#d2#u3#u4#u5#u6#u7#u8#d9#d0#d1") w.plptex(0.5, 0.8, 1., 0., 0.5, "X#u0#u#<italic/>1#u2#d3#d4#d5#d6#d7#d8#u9#u0#u1") w.plptex(0.5, 0.6, 1., 0., 0.5, "#ga#uaa#gad#gdp#gr#gf#d, #ga#u#ga#gaad#gdp#gr#gf#d, B#ua#<italic/>a#gad#gdp#gr#gf#d, B#u#ga#gaad#gdp#gr#gf#d") w.plptex(0.5, 0.4, 1., 0., 0.5, "#ga#daa#gad#gdp#gr#gf#u, #ga#d#ga#gaad#gdp#gr#gf#u, B#da#<italic/>a#gad#gdp#gr#gf#u, B#d#ga#gaad#gdp#gr#gf#u") w.plptex(0.5, 0.2, 1., 0., 1.1, "B#uf#d, B#ur#d") w.plptex(0.5, 0.2, 1., 0., -0.1, "B#df#u, B#dr#u") w.pladv(0) w.plvpor(0.2, 0.8, 0.2, 0.8) w.plwind(0., 1.e-200, 0., 1.e-200) w.plbox("bcmnt", 0., 0, "bcmntv", 0., 0) # Some fiducial marks that show yoffset problems with the pdf device. w.plmtex("t", -5.125, 0.1, 0.5, "X") w.plmtex("t", -5.125, 0.2, 0.5, "X#d") w.plmtex("t", -5.125, 0.3, 0.5, "X#u") #w.plmtex("t", -10.250, 0.1, 0.5, "X") #w.plmtex("t", -15.375, 0.1, 0.5, "X") #w.plmtex("t", -20.500, 0.1, 0.5, "X") # Roughly duplicate w.plptex tests of superscript/subscript. w.plmtex("t", -5.125, 0.5, 0.5, "X#d0#d1#d2#u3#u4#u5#u6#u7#u8#d9#d0#d1") w.plmtex("t", -5.125, 0.5, 0.5, "X#u0#u1#u2#d3#d4#d5#d6#d7#d8#u9#u0#u1") w.plmtex("t", -10.250, 0.5, 0.5, "#ga#uaa#gad#gdp#gr#gf#d, #ga#u#ga#gaad#gdp#gr#gf#d, B#uaa#gad#gdp#gr#gf#d, B#u#ga#gaad#gdp#gr#gf#d") w.plmtex("t", -15.375, 0.5, 0.5, "#ga#daa#gad#gdp#gr#gf#u, #ga#d#ga#gaad#gdp#gr#gf#u, B#daa#gad#gdp#gr#gf#u, B#d#ga#gaad#gdp#gr#gf#u") w.plmtex("t", -20.500, 0.5, 1.1, "B#uf#d, B#ur#d") w.plmtex("t", -20.500, 0.5, -0.1, "B#df#u, B#dr#u") # These four tests mimic what occurs for badly scaled w.plbox axes.
# Parse and process command line arguments w.plparseopts(sys.argv, w.PL_PARSE_FULL) # Initialize plplot w.plinit() for kind in range(len(title)): 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.plcol0(1) w.plbox("bc", 0., 0, "bc", 0., 0) w.plcol0(2) w.plschr(0., 1.) w.plmtex("t", 1., 0.5, 0.5, title[kind]) k = 0 for size in 2.**arange(2, -3, -1): k += 1 w.plcol0(k) if kind == 0: if ifunicode: w.plschr(0., 4. * size) # LARGE CIRCLE has a centre of symmetry which is about one-eighth the # radius below the centre of symmetry of the box for DejaVu Sans. w.plptex(0.5, 0.5, 1., 0., 0.5, "#[0x25ef]") # BOX DRAWINGS LIGHT DIAGONAL CROSS is one of the best centred symmetrical # glyphs I have found using gucharmap for DejaVu Sans. w.plptex(0.5, 0.5, 1., 0., 0.5, "#[0x2573]") else: w.plschr(0., 4. * size)
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() plplot.plenv(xMin2D, xMax2D, yMin2D, yMax2D, 0, -2) plplot.plw3d(basex, basey, height, xMin, xMax, yMin, yMax, zMin, zMax, alt, az)