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()
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): 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()
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.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")
# -*- 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()
#!/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() # Choose 5 here so there is room for non-exponential notation for an axis # label of +0.08. w.plsyax(5, 0) w.pladv(0) w.plvpor(0.1, 0.9, 0.1, 0.9) w.plwind(0.00, 1.00, 0.00, 0.08) w.plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0); w.plend()