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 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)
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): 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")
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.2, 0.8, 0.2, 0.8) w.plwind(0., 1., 0., 1.) 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")
# -*- 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()
# 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) # Large circle via Hershey fonts. w.plptex(0.5, 0.5, 1., 0., 0.5, "#(907)") elif kind == 1: # Print a utf-8 plus w.plschr(0., 16. * size) w.plstring(x, y, "+") elif kind == 2: # Print a utf-8 squared plus w.plschr(0., 16. * size) w.plstring(x, y, "⊞")