def __init__(self): gtk.Window.__init__(self) self.set_title("GtkPlotPolar Demo") self.set_size_request(500, 320) colormap = self.get_colormap() red = colormap.alloc_color("red") scrollwin = gtk.ScrolledWindow() scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.add(scrollwin) canvas = gtkextra.PlotCanvas(gtkextra.PLOT_LETTER_W, gtkextra.PLOT_LETTER_H) canvas.plot_canvas_set_flags(gtkextra.PLOT_CANVAS_DND_FLAGS) scrollwin.add_with_viewport(canvas) plot = gtkextra.PlotPolar() plot.resize(width=0.5, height=0.25) canvas.add_plot(plot, 0.15, 0.06) r = [0.2, 0.34, 0.45, 0.6, 0.75, 0.81] angle = [15.0, 20.0, 43.0, 67.0, 84.0, 106.0] data = gtkextra.PlotData() data.set_points(x=r, y=angle) data.set_symbol(gtkextra.PLOT_SYMBOL_DIAMOND, gtkextra.PLOT_SYMBOL_OPAQUE, 10, 2, red, red) data.set_line_attributes(gtkextra.PLOT_LINE_SOLID, 0, 0, 1, red) data.set_legend("Example") plot.add_data(data) self.show_all()
def build_example1(self, plot): px1 = [0., .2, .4, .6, .8, 1.] py1 = [.2, .4, .5, .35, .30, .40] dx1 = [.2, .2, .2, .2, .2, .2] dy1 = [.1, .1, .1, .1, .1, .1] px2 = [0., -.2, -.4, -.6, -.8, -1.] py2 = [.2, .4, .5, .35, .30, .40] dx2 = [.2, .2, .2, .2, .2, .2] dy2 = [.1, .1, .1, .1, .1, .1] colormap = self.get_colormap() red = colormap.alloc_color("red") black = colormap.alloc_color("black") blue = colormap.alloc_color("blue") data = gtkextra.PlotData() data.show() plot.add_data(data) data.set_points(x=px1, y=py1, dx=dx1, dy=dy1) data.set_symbol(gtkextra.PLOT_SYMBOL_DIAMOND, gtkextra.PLOT_SYMBOL_EMPTY, 10, 2, red, red) data.set_line_attributes(gtkextra.PLOT_LINE_SOLID, 0, 0, 1, red) data.set_connector(gtkextra.PLOT_CONNECT_SPLINE) data.show_yerrbars() data.set_legend("Spline + EY") data.show_labels(True) data.set_labels(['0', '1', '2', '3', '4', '5']) data = gtkextra.PlotData() data.show() plot.add_data(data) data.set_points(x=px2, y=py2, dx=dx2, dy=dy2) data.set_symbol(gtkextra.PLOT_SYMBOL_SQUARE, gtkextra.PLOT_SYMBOL_OPAQUE, 8, 2, black, black) data.set_line_attributes(gtkextra.PLOT_LINE_SOLID, 0, 0, 4, red) data.set_connector(gtkextra.PLOT_CONNECT_STRAIGHT) data.set_x_attributes(gtkextra.PLOT_LINE_SOLID, 0, 0, 0, black) data.set_y_attributes(gtkextra.PLOT_LINE_SOLID, 0, 0, 0, black) data.set_legend("Line + Symbol") data = plot.add_function(self.function) data.show() data.set_line_attributes(gtkextra.PLOT_LINE_SOLID, 0, 0, 0, blue) data.set_legend("Function Plot")
def __init__(self): gtk.Window.__init__(self) self.set_title("GtkPlot Real Time Demo") self.set_size_request(550, 600) colormap = self.get_colormap() red = colormap.alloc_color("red") light_blue = colormap.alloc_color("light blue") light_yellow = colormap.alloc_color("light yellow") white = colormap.alloc_color("white") scrollwin = gtk.ScrolledWindow() scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.add(scrollwin) self.canvas = canvas = gtkextra.PlotCanvas(gtkextra.PLOT_LETTER_W, gtkextra.PLOT_LETTER_H) canvas.set_background(light_blue) scrollwin.add_with_viewport(canvas) plot = gtkextra.Plot(width=0.65, height=0.45) plot.set_background(light_yellow) plot.legends_set_attributes(None, 0, None, white) plot.set_range(0.0, 20.0, 0.0, 1.0) plot.axis_set_ticks(gtkextra.PLOT_AXIS_X, 2.0, 1) plot.axis_set_ticks(gtkextra.PLOT_AXIS_Y, 0.1, 1) plot.axis_set_labels_style(gtkextra.PLOT_AXIS_TOP, gtkextra.PLOT_LABEL_FLOAT, 0) plot.axis_set_labels_style(gtkextra.PLOT_AXIS_BOTTOM, gtkextra.PLOT_LABEL_FLOAT, 0) plot.axis_set_visible(gtkextra.PLOT_AXIS_TOP, gtk.TRUE) plot.axis_set_visible(gtkextra.PLOT_AXIS_RIGHT, gtk.TRUE) plot.grids_set_visible(gtk.TRUE, gtk.TRUE, gtk.TRUE, gtk.TRUE) plot.axis_hide_title(gtkextra.PLOT_AXIS_TOP) plot.axis_hide_title(gtkextra.PLOT_AXIS_RIGHT) plot.axis_set_title(gtkextra.PLOT_AXIS_LEFT, "Intensity") plot.axis_set_title(gtkextra.PLOT_AXIS_BOTTOM, "Point") plot.set_legends_border(gtkextra.PLOT_BORDER_SHADOW, 3) plot.legends_move(0.60, 0.10) canvas.add_plot(plot, 0.15, 0.15) canvas.put_text(0.45, 0.05, "Times-BoldItalic", 20, 0, None, None, gtk.TRUE, gtk.JUSTIFY_CENTER, "Iterator Demo") mask = gtkextra.PLOT_DATA_X | gtkextra.PLOT_DATA_Y | gtkextra.PLOT_DATA_LABELS data = gtkextra.PlotData(self.iterator, 20, mask) data.show_labels(gtk.TRUE) plot.add_data(data) data.set_legend("Iterator") data.set_symbol(gtkextra.PLOT_SYMBOL_DIAMOND, gtkextra.PLOT_SYMBOL_OPAQUE, 10, 2, red, red) data.set_line_attributes(gtkextra.PLOT_LINE_SOLID, 0, 0, 1, red) self.show_all()
def __init__(self): gtk.Window.__init__(self) self.set_title("Bubbles Demo") self.set_size_request(550, 650) self.connect("destroy", lambda win: gtk.main_quit()) colormap = self.get_colormap() blue = colormap.alloc_color("blue") scrollwin = gtk.ScrolledWindow() scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.add(scrollwin) self.canvas = canvas = gtkextra.PlotCanvas(gtkextra.PLOT_LETTER_W, gtkextra.PLOT_LETTER_H) canvas.plot_canvas_set_flags(gtkextra.PLOT_CANVAS_DND_FLAGS) scrollwin.add_with_viewport(canvas) plot = gtkextra.Plot(width=0.5, height=0.25) plot.legends_move(0.05, 0.05) plot.set_legends_border(0, 0) plot.axis_hide_title(gtkextra.PLOT_AXIS_TOP) plot.axis_show_ticks(gtkextra.PLOT_AXIS_BOTTOM, 15, 3) plot.axis_set_visible(gtkextra.PLOT_AXIS_TOP, gtk.TRUE) plot.axis_set_visible(gtkextra.PLOT_AXIS_RIGHT, gtk.TRUE) plot.grids_set_visible(gtk.TRUE, gtk.TRUE, gtk.TRUE, gtk.TRUE) canvas.add_plot(plot, 0.15, 0.06) px1 = [0., 0.1, 0.2, 0.3, 0.4, 0.5, .6, .7, .8, .9] py1 = [.2, .4, .5, .35, .30, .40, .45, .56, .76, .87] pa1 = [.12, .22, .27, .12, .052, .12, .045, .214, .123, .088] pda1 = [.132, .23, .432, .34, .46, .56, .785, .76, .86, .89] data = gtkextra.PlotData() data.set_points(x=px1, y=py1, a=pa1, da=pda1) data.set_symbol(gtkextra.PLOT_SYMBOL_CIRCLE, gtkextra.PLOT_SYMBOL_OPAQUE, 10, 2, blue, blue) data.set_line_attributes(gtkextra.PLOT_LINE_NONE, 0, 0, 1, blue) data.set_legend("Bubbles") data.gradient_set_visible(gtk.TRUE) plot.add_data(data) self.show_all()
def __init__(self): #gtk.Window.__init__(self) self.__gobject_init__() self.set_title("GtkPlot Real Time Demo") self.set_size_request(550, 600) self.connect("destroy", self.quit) colormap = self.get_colormap() red = colormap.alloc_color("red") light_blue = colormap.alloc_color("light blue") light_yellow = colormap.alloc_color("light yellow") white = colormap.alloc_color("white") scrollwin = gtk.ScrolledWindow() scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.add(scrollwin) self.canvas = canvas = gtkextra.PlotCanvas(gtkextra.PLOT_LETTER_W, gtkextra.PLOT_LETTER_H) canvas.set_background(light_blue) canvas.connect("button_press_event", self.button_press_handler) scrollwin.add_with_viewport(canvas) plot = gtkextra.Plot() plot.resize(width=0.65, height=0.45) plot.set_background(light_yellow) plot.legends_set_attributes(None, 0, None, white) plot.set_legends_border(gtkextra.PLOT_BORDER_SHADOW, 3) plot.legends_move(0.60, 0.10) plot.set_range(0.0, 20.0, 0.0, 1.0) plot.set_ticks(gtkextra.PLOT_AXIS_X, 2, 1) plot.set_ticks(gtkextra.PLOT_AXIS_Y, .1, 1) axis_left = plot.get_axis(gtkextra.PLOT_AXIS_LEFT) axis_right = plot.get_axis(gtkextra.PLOT_AXIS_RIGHT) axis_top = plot.get_axis(gtkextra.PLOT_AXIS_TOP) axis_bottom = plot.get_axis(gtkextra.PLOT_AXIS_BOTTOM) axis_x = plot.get_axis(gtkextra.PLOT_AXIS_X) axis_y = plot.get_axis(gtkextra.PLOT_AXIS_Y) axis_top.set_labels_style(gtkextra.PLOT_LABEL_FLOAT, 0) axis_bottom.set_labels_style(gtkextra.PLOT_LABEL_FLOAT, 0) axis_top.set_visible(True) axis_right.set_visible(True) plot.grids_set_visible(True, True, True, True) axis_top.hide_title() axis_right.hide_title() axis_left.set_title("Intensity") axis_bottom.set_title("Time (s)") child = gtkextra.PlotCanvasPlot(plot) canvas.put_child(child, .15, .15, .80, .65); plot.show() child = gtkextra.PlotCanvasText("Times-BoldItalic", 20, 0, None, None, True, gtk.JUSTIFY_CENTER, "Real Time Demo") canvas.put_child(child, .45, .05, 0., 0.) data = gtkextra.PlotData() plot.add_data(data) data.show() data.set_legend("Random pulse") data.set_symbol(gtkextra.PLOT_SYMBOL_DIAMOND, gtkextra.PLOT_SYMBOL_OPAQUE, 10, 2, red, red) data.set_line_attributes(gtkextra.PLOT_LINE_SOLID, 0, 0, 1, red) plot.clip_data(True) canvas.paint() canvas.refresh() self.show_all() gobject.timeout_add(100, self.update, canvas, plot, data)