Exemple #1
0
 def on_draw(self, widget, ctx):
     if self.data is not None:
         data = self.filter_data()
         cairoplot.scatter_plot(ctx,
                                data=data,
                                width=widget.get_allocated_width(),
                                height=widget.get_allocated_height(),
                                x_bounds=(min(data[0]) * 0.98,
                                          max(data[0]) * 1.02),
                                y_bounds=(min(data[1]) * 0.98,
                                          max(data[1]) * 1.02),
                                border=20,
                                axis=True,
                                grid=True,
                                dots=1,
                                discrete=True,
                                series_colors=[(0.0, 0.0, 0.0)],
                                background="white")
Exemple #2
0
 def test_plot(self):
     import cairoplot
     x, y = self.drive()
     cairoplot.scatter_plot("plot.png", [x, y])
Exemple #3
0
    def graphAD(self):
         #Graphs Origin-Boarding Locations
        try:
            #Check Inputs
            if 1==1: 
                #self.modeFromCombo.get() and self.oxCombo.get() and self.oyCombo.get() and self.bxCombo.get() and self.byCombo.get() and self.surveyBusCombo.get() and self.firstBusCombo.get():
                ###Not needed
                #SurveyIDField=self.idCombo.get()
                #ModeFrField=self.modeFrCombo.get()
                #AXField=self.axCombo.get()
                #AYField=self.ayCombo.get()
                #DXField=self.dxCombo.get()
                #DYField=self.dyCombo.get()
                
                ## Debugging
                ##ModeToField=self.modeToCombo.get()
                ModeFromField="DGET"
                ##DXField=self.oxCombo.get()
                DXField="DXCORD"
                ##OYField=self.oyCombo.get()
                DYField="DYCORD"
                ##BXField=self.bxCombo.get()
                AXField="AX"
                ##BYField=self.byCombo.get()
                AYField="AY"
                ##sBusField=self.surveyBusCombo.get()
                sBusField="RTCODE"
                ##fBusField=self.firstBusCombo.get()
                fBusField="BUS1"
                #read all this stuff into an array
                rows=arcpy.SearchCursor(self.tableLB.get())
                x=1
                rowData=[]
                for row in rows:
                    if(row.getValue("BUS4")):
                        lastBus=row.getValue("BUS4")
                    elif(row.getValue("BUS3")):
                        lastBus=row.getValue("BUS3")
                    elif(row.getValue("BUS2")):
                        lastBus=row.getValue("BUS2")
                    else:
                        lastBus=row.getValue("BUS1")
                    if(x % 100 == 0):
                        print "Reading on ",x
                    if(row.getValue(sBusField)==lastBus):
                        if(row.getValue(DXField)>0 and row.getValue(AXField)>0 and row.getValue(DYField)>0 and row.getValue(AYField)>0):
                            iRow=[row.getValue(ModeFromField),math.sqrt(math.pow(row.getValue(DXField)-row.getValue(AXField),2)+math.pow(row.getValue(DYField)-row.getValue(AYField),2))/5280]
                            rowData.append(iRow)

                    
                        
                newRowData=self.sortList(rowData)
                #Graph creation
                iWalk=0
                iBike=0
                iDrive=0
                graphItemsWalk=[]
                graphItemsBike=[]
                graphItemsDrive=[]
                    
                for item in newRowData:
                    if(item[0]==1):
                        graphItemsWalk.append((iWalk,item[1]))
                        iWalk+=1
                    elif(item[0]==2):
                        graphItemsBike.append((iBike,item[1]))
                        iBike+=1
                    else:
                        graphItemsDrive.append((iDrive,item[1]))
                        iDrive+=1
                        
                if(iWalk==0):
                    graphItemsWalk.append((0,0))
                    iWalk=1
                if(iBike==0):
                    graphItemsBike.append((0,0))
                    iBike=1
                if(iDrive==0):
                    graphItemsDrive.append((0,0))
                    iDrive=1
                graphItems=[]
                giWalk=[]
                giBike=[]
                giDrive=[]
                
                for item in graphItemsWalk:
                    giWalk.append((item[0]*100/iWalk,item[1]))
                for item in graphItemsBike:
                    giBike.append((item[0]*100/iBike,item[1]))
                for item in graphItemsDrive:
                    giDrive.append((item[0]*100/iDrive,item[1]))

                graphItems.append(giWalk)
                graphItems.append(giBike)
                graphItems.append(giDrive)

                cairoplot.scatter_plot('C:\\GraphA2D.SVG',data=graphItems,width=600,height=400,border=20,axis=True,grid=True,series_colors=[(1,0,0),(0,1,0),(0,0,1)],y_title='Miles')
                cairoplot.scatter_plot('C:\\GraphA2D_Walk.SVG',data=graphItemsWalk,width=600,height=400,border=20,axis=True,grid=True,series_colors=[(1,0,0)],y_title='Miles')
                cairoplot.scatter_plot('C:\\GraphA2D_Bike.SVG',data=graphItemsBike,width=600,height=400,border=20,axis=True,grid=True,series_colors=[(1,0,0)],y_title='Miles')
                cairoplot.scatter_plot('C:\\GraphA2D_Drive.SVG',data=graphItemsDrive,width=600,height=400,border=20,axis=True,grid=True,series_colors=[(1,0,0)],y_title='Miles')
                
                print "Completed for now"
        except Exception as e:
            tkMessageBox.showerror("Problem somewhere",e.message)
Exemple #4
0
test_function_plot = 1
# Bar plotting
test_vertical_bar_plot = 1
test_horizontal_bar_plot = 1
# Pie plotting
test_pie_plot = 1
test_donut_plot = 1
# Others
test_gantt_chart = 1
test_themes = 1


if test_scatter_plot:
    #Default data
    data = Series([ (-2,10), (0,0), (0,15), (1,5), (2,0), (3,-10), (3,5) ])
    cairoplot.scatter_plot ( 'scatter_1_default_series.png', data = data, width = 500, height = 500, border = 20, axis = True, grid = True )
    
    #lists of coordinates x,y
    data = Series([[[1,2,3,4,5],[1,1,1,1,1]]])
    cairoplot.scatter_plot ( 'scatter_2_lists_series.png', data = data, width = 500, height = 500, border = 20, axis = True, grid = True )
    
    #lists of coordinates x,y,z
    data = Series([[[0.5,1,2,3,4,5],[0.5,1,1,1,1,1],[10,6,10,20,10,6]]])
    colors = [ (0,0,0,0.25), (1,0,0,0.75) ]
    cairoplot.scatter_plot ( 'scatter_3_lists_series.png', data = data, width = 500, height = 500, border = 20, axis = True, discrete = True,
                             grid = True, circle_colors = colors )    
    
    data = Series([(-1, -16, 12), (-12, 17, 11), (-4, 6, 5), (4, -20, 12), (13, -3, 21), (7, 14, 20), (-11, -2, 18), (19, 7, 18), (-10, -19, 15),
                  (-17, -2, 6), (-9, 4, 10), (14, 11, 16), (13, -11, 18), (20, 20, 16), (7, -8, 15), (-16, 17, 16), (16, 9, 9), (-3, -13, 25),
                  (-20, -6, 17), (-10, -10, 12), (-7, 17, 25), (10, -10, 13), (10, 13, 20), (17, 6, 15), (18, -11, 14), (18, -12, 11), (-9, 11, 14),
                  (17, -15, 25), (-2, -8, 5), (5, 20, 20), (18, 20, 23), (-20, -16, 17), (-19, -2, 9), (-11, 19, 18), (17, 16, 12), (-5, -20, 15),
Exemple #5
0
test_function_plot = 1
# Bar plotting
test_vertical_bar_plot = 1
test_horizontal_bar_plot = 1
# Pie plotting
test_pie_plot = 1
test_donut_plot = 1
# Others
test_gantt_chart = 1
test_themes = 1


if test_scatter_plot:
    #Default data
    data = [ (-2,10), (0,0), (0,15), (1,5), (2,0), (3,-10), (3,5) ]
    cairoplot.scatter_plot ( 'scatter_1_default.svg', data = data, width = 500, height = 500, border = 20, axis = True, grid = True )
    
    #lists of coordinates x,y
    data = [[1,2,3,4,5],[5,4,3,2,1]]
    cairoplot.scatter_plot ( 'scatter_2_lists.svg', data = data, width = 500, height = 500, border = 20, axis = True, grid = True )

    #lists of coordinates x,y,z
    data = [[[1,2,3,4,5],[2.5,2.5,2.5,2.5,2.5],[6,10,20,10,6]]]
    colors = [ (0,0,0,0.25), (1,0,0,0.75) ]
    cairoplot.scatter_plot ( 'scatter_3_lists.svg', data = data, width = 500, height = 500, border = 20, axis = True, discrete = True,
                             grid = True, x_bounds=(0,6), y_bounds=(0,5), circle_colors = colors ) 
    
    data = [(-1, -16, 12), (-12, 17, 11), (-4, 6, 5), (4, -20, 12), (13, -3, 21), (7, 14, 20), (-11, -2, 18), (19, 7, 18), (-10, -19, 15),
            (-17, -2, 6), (-9, 4, 10), (14, 11, 16), (13, -11, 18), (20, 20, 16), (7, -8, 15), (-16, 17, 16), (16, 9, 9), (-3, -13, 25),
            (-20, -6, 17), (-10, -10, 12), (-7, 17, 25), (10, -10, 13), (10, 13, 20), (17, 6, 15), (18, -11, 14), (18, -12, 11), (-9, 11, 14),
            (17, -15, 25), (-2, -8, 5), (5, 20, 20), (18, 20, 23), (-20, -16, 17), (-19, -2, 9), (-11, 19, 18), (17, 16, 12), (-5, -20, 15),