def __init__(self): # add graph self.graph = CaGraphFile() # create and add axiss to graph xaxis = CaGraphXAxis(self.graph) yaxis = CaGraphYAxis(self.graph) self.graph.axiss.append(xaxis) self.graph.axiss.append(yaxis) # create and add series to graph self.graph.seriess.append(CaGraphSeriesLine(self.graph, 0, 1)) self.graph.seriess.append(CaGraphSeriesLine(self.graph, 0, 1)) # add data to seriess self.graph.seriess[0].data = [(10.0, 52.0), (20.0, 70.0), (30.0, 53.0), (40.0, 38), (50.0, 75.0), (60.0, 85.0), (70.0, 65.0)] self.graph.seriess[1].style.line_color = (1.0, 0.0, 0.0, 1.0) self.graph.seriess[1].data = [(10.0, 42.0), (20.0, 50.0), (30.0, 63.0), (40.0, 68), (50.0, 75.0), (60.0, 95.0), (70.0, 65.0)] # automaticaly set axis ranges self.graph.auto_set_range()
def __init__(self): # create widget tree ... xml = gtk.glade.XML('test.glade') # connect handlers xml.signal_autoconnect(self) # widgets self.main_window = xml.get_widget('main_window') self.hbox_graph = xml.get_widget('hbox_graph') # add graph self.graph = CaGraph() self.hbox_graph.pack_start(self.graph) # create and add axiss to graph xaxis = CaGraphXAxis(self.graph) yaxis = CaGraphYAxis(self.graph) self.graph.axiss.append(xaxis) self.graph.axiss.append(yaxis) # create and add series to graph self.graph.seriess.append(CaGraphSeriesLine(self.graph, 0, 1)) self.graph.seriess.append(CaGraphSeriesHBar(self.graph, 0, 1)) self.graph.seriess.append(CaGraphSeriesLabels(self.graph, 0, 1)) # add data to seriess # add data to seriess self.graph.seriess[0].data = [(52.0, 10.0), (70.0, 20.0), (53.0, 30.0), (38, 40.0), (75.0, 50.0), (85.0, 60.0), (65.0, 70.0)] self.graph.seriess[1].data = [(32.0, 10.0), (10.0, 20.0), (33.0, 30.0), (38, 40.0), (55.0, 50.0), (65.0, 60.0), (75.0, 70.0)] self.graph.seriess[2].data = [(32.0, 10.0, u'point 1'), (10.0, 20.0, u'point 2'), (33.0, 30.0, u'point 3'), (38, 40.0, u'point 4'), (55.0, 50.0, u'point 5'), (65.0, 60.0, u'point 6'), (75.0, 70.0, u'point 7')] # add labels # automaticaly set axis ranges self.graph.auto_set_range() # show wigdet self.graph.show() # draw to file self.graph.draw_to_file('example8.svg') self.graph.draw_to_file('example8.png')
def __init__(self): # create widget tree ... xml = gtk.glade.XML('example7.glade') # connect handlers xml.signal_autoconnect(self) # widgets self.main_window = xml.get_widget('main_window') self.vbox_graph = xml.get_widget('vbox_graph') self.label_xy0 = xml.get_widget('label_xy0') self.label_xy1 = xml.get_widget('label_xy1') # add graph self.graph = CaGraph(self.main_window) self.vbox_graph.pack_start(self.graph) # show pointer line self.graph.graph_style.draw_pointer = True # create and add axiss to graph xaxis = CaGraphXAxis(self.graph) yaxis = CaGraphYAxis(self.graph) self.graph.axiss.append(xaxis) self.graph.axiss.append(yaxis) # create and add series to graph self.graph.seriess.append(CaGraphSeriesLine(self.graph, 0, 1)) self.graph.seriess.append(CaGraphSeriesBar(self.graph, 0, 1)) # add data to seriess self.graph.seriess[0].data = [(10.0, 52.0), (20.0, 70.0), (30.0, 53.0), (40.0, 38), (50.0, 75.0), (60.0, 85.0), (70.0, 65.0)] self.graph.seriess[1].data = [(10.0, 42.0), (20.0, 50.0), (30.0, 63.0), (40.0, 68), (50.0, 75.0), (60.0, 95.0), (70.0, 65.0)] # automaticaly set axis ranges self.graph.auto_set_range() # show x,y data in a label when the mouse is over the graph self.main_window.connect('motion-notify-event', self.motion_notify) # show wigdet self.graph.show()
def __init__(self): # create widget tree ... xml = gtk.glade.XML('test.glade') # connect handlers xml.signal_autoconnect(self) # widgets self.main_window = xml.get_widget('main_window') self.hbox_graph = xml.get_widget('hbox_graph') # add graph self.graph = CaGraph() self.hbox_graph.pack_start(self.graph) # create and add axiss to graph xaxis = CaGraphXAxis(self.graph) yaxis = CaGraphYAxis(self.graph) self.graph.axiss.append(xaxis) self.graph.axiss.append(yaxis) # create and add series to graph self.graph.seriess.append(CaGraphSeriesLine(self.graph, 0, 1)) self.graph.seriess.append(CaGraphSeriesBar(self.graph, 0, 1)) # add data to seriess self.graph.seriess[0].data = [(10.0, 52.0), (20.0, 70.0), (30.0, 53.0), (40.0, 38), (50.0, 75.0), (60.0, 85.0), (70.0, 65.0)] self.graph.seriess[1].data = [(10.0, 42.0), (20.0, 50.0), (30.0, 63.0), (40.0, 68), (50.0, 75.0), (60.0, 95.0), (70.0, 65.0)] # automaticaly set axis ranges self.graph.auto_set_range() # show wigdet self.graph.show() # draw to file self.graph.draw_to_file('example1.svg') self.graph.draw_to_file('example1.png')
def __init__(self): # create widget tree ... xml = gtk.glade.XML('test.glade') # connect handlers xml.signal_autoconnect(self) # widgets self.main_window = xml.get_widget('main_window') self.hbox_graph = xml.get_widget('hbox_graph') # add graph self.graph = CaGraph() self.hbox_graph.pack_start(self.graph) # add axiss to graph self.graph.axiss.append(CaGraphTAxis(self.graph)) self.graph.axiss.append(CaGraphYAxis(self.graph)) # top axis top_axis = CaGraphXAxis(self.graph) top_axis.axis_style.side = 'top' top_axis.axis_style.draw_labels = False self.graph.axiss.append(top_axis) # right axis right_axis = CaGraphYAxis(self.graph) right_axis.axis_style.side = 'right' right_axis.axis_style.draw_labels = False self.graph.axiss.append(right_axis) # add series to graph self.graph.seriess.append(CaGraphSeriesLine(self.graph, 0, 1)) self.graph.seriess.append(CaGraphSeriesBar(self.graph, 0, 1)) self.graph.seriess.append(CaGraphSeriesArea(self.graph, 0, 1)) # add data self.graph.seriess[0].data = [ (-10.0,-12.0),(0.0,12.0), (10.0,23.0),(20.0,18), (30.0,-5.0), (40.0,-15.0), (50.0,15.0)] self.graph.seriess[1].data = [ (-14.0,-1.0),(0.0,2.0), (10.0,33.0),(20.0,8), (30.0,-1.0), (40.0,-1.0), (50.0,19.0)] self.graph.seriess[2].data = [ (-10.0,-10.0),(0.0,8.0), (10.0,23.0),(20.0,14.0), (30.0,-2.0), (40.0,-3.0), (50.0,8.0)] # set axis ranges self.graph.auto_set_range() # add grid self.graph.grid = CaGraphGrid(self.graph, 0, 1) self.graph.show() # draw to file self.graph.draw_to_file('test.svg', 600, 600)
def __init__(self): # create widget tree ... xml = gtk.glade.XML('test.glade') # connect handlers xml.signal_autoconnect(self) # widgets self.main_window = xml.get_widget('main_window') self.hbox_graph = xml.get_widget('hbox_graph') # add graph self.graph = CaGraph() self.hbox_graph.pack_start(self.graph) # create and add axiss to graph xaxis = CaGraphXAxis(self.graph) yaxis = CaGraphYAxis(self.graph) self.graph.axiss.append(xaxis) self.graph.axiss.append(yaxis) # create and add top axis top_axis = CaGraphXAxis(self.graph) top_axis.axis_style.side = 'top' top_axis.axis_style.draw_labels = False self.graph.axiss.append(top_axis) # create and add right axis right_axis = CaGraphYAxis(self.graph) right_axis.axis_style.side = 'right' right_axis.axis_style.draw_labels = False self.graph.axiss.append(right_axis) # create and add series to graph series1 = CaGraphSeriesLine(self.graph, 0, 1) series2 = CaGraphSeriesArea(self.graph, 0, 1) series3 = CaGraphSeriesLine(self.graph, 0, 1) self.graph.seriess.append(series2) self.graph.seriess.append(series3) self.graph.seriess.append(series1) # set line style series1.style.line_color = (1.0, 0.0, 0.0, 1.0) series1.style.line_width = 2.0 series1.style.point_type = '' series2.style.line_color = (0.0, 1.0, 0.0, 1.0) series2.style.fill_color = (0.0, 1.0, 0.0, 0.3) series2.style.line_width = 2.0 series2.style.point_type = '' series3.style.line_color = (0.0, 0.6, 0.0, 1.0) series3.style.line_width = 0.0 series3.style.point_type = 'o' # add data to seriess for i in range(-360, 720): alpha = math.pi * i / 180.0 series1.data.append((alpha, math.sin(alpha))) series2.data.append((alpha, math.cos(alpha))) for i in range(-360, 720, 20): alpha = math.pi * i / 180.0 series3.data.append((alpha, math.cos(alpha))) # automaticaly set axis ranges self.graph.auto_set_range() # add grid self.graph.grid = CaGraphGrid(self.graph, 0, 1) # show wigdet self.graph.show() # draw to file self.graph.draw_to_file('example3.svg', 700, 300) self.graph.draw_to_file('example3.png', 700, 300)