def cmap1_init(w, gray): # Independent variable of control points. i = array((0., 1.)) if gray: # Hue for control points. Doesn't matter since saturation is zero. h = array((0., 0.)) # Lightness ranging from half-dark (for interest) to light. l = array((0.5, 1.)) # Gray scale has zero saturation s = array((0., 0.)) else: # Hue ranges from blue (240 deg) to red (0 or 360 deg) h = array((240., 0.)) # Lightness and saturation are constant (values taken from C example). l = array((0.6, 0.6)) s = array((0.8, 0.8)) # number of cmap1 colours is 256 in this case. w.plscmap1n(256) # Interpolate between control points to set up cmap1. w.plscmap1l(0, i, h, l, s)
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()