当前位置: 首页>>代码示例>>Python>>正文


Python Graph.xlabel方法代码示例

本文整理汇总了Python中Graph.Graph.xlabel方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.xlabel方法的具体用法?Python Graph.xlabel怎么用?Python Graph.xlabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graph.Graph的用法示例。


在下文中一共展示了Graph.xlabel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DevelopmentWindow

# 需要导入模块: from Graph import Graph [as 别名]
# 或者: from Graph.Graph import xlabel [as 别名]
class DevelopmentWindow():

    def __init__(self):
        self.worlds = []
        ## Set up worlds
        fLocs1 = [(2,0),(-2,0),(0,2),(0,-2),(0,3),(0,-3),(3,0),(-3,0),(4,0),(-4,0),(0,4),(0,-4),(0,7),(7,0),(-7,0)]
        fLocs2 = [(1,1),(2,2),(3,3),(4,4),(3,5),(2,6),(1,7),(0,8),(-2,6),(-4,4),(-6,2),(-8,0),(-5,0),(-2,-3),(-5,-5)]
        fLocs3 = [(-2,2),(-1,0),(1,0),(-1,0),(2,-2),(3,5),(-5,5),(-8,8),(10,10),(-10,10),(10,-10),(0,-1),(0,-2),(0,-3),(0,-4)]
        fLocs4 = [(random.random()*20 - 20.0/2., random.random()*20 - 20.0/2.) for i in xrange(20)]
        fLocs5 = [(random.random()*20 - 20.0/2., random.random()*20 - 20.0/2.) for i in xrange(20)]
        self.worlds.append([1,15,20,fLocs1])
        self.worlds.append([1,15,20,fLocs2])
        self.worlds.append([1,15,20,fLocs3])
        self.worlds.append([1,20,20,fLocs4])
        self.worlds.append([1,20,20,fLocs5])

        #parameters
        self.sP = SimParam.SimParam()
        self.sP.setWorld(1,self.worlds[0][0],self.worlds[0][1],self.worlds[0][2],self.worlds[0][3])   #change first index to change default world
        self.sP.setWorld(2,self.worlds[1][0],self.worlds[1][1],self.worlds[1][2],self.worlds[1][3])
        self.sP.setWorld(3,self.worlds[2][0],self.worlds[2][1],self.worlds[2][2],self.worlds[2][3])
        self.sP.setWorld(4,self.worlds[3][0],self.worlds[3][1],self.worlds[3][2],self.worlds[3][3])
        self.sP.setWorld(5,self.worlds[4][0],self.worlds[4][1],self.worlds[4][2],self.worlds[4][3])
        self.sP.setAnimParams(1,1,(0,0))
        self.paused = True                     #paused?
        self.lastTime = 0
        self.sim_msps = 0
        self.dis_t = 1                         #the t being displayed
        self.buff_t = 0
        self.writeInterval = 100
        self.simHistory = {}                    #this will fill with produced worlds from the simulations
        self.simEngine = SimulationEngine.SimulationEngine()
        self.developmentHistory = {}
        self.layoutHist = 300                   #y value holder for new aniimat config button placement
        self.layoutList = []                    # holds config/delete animat buttons and labels for any animats other than default

        #intialize TK
        self.root = tk.Tk()
        self.root.title("Development Simulation")
        self.canvas = tk.Canvas(self.root, width=1080, height=720)
        self.canvas.pack()

        #some general-purpose colors
        self.colorWhite = "#ffffff"
        self.colorGrey = "#dddddd"
        self.colorBlack = "#000000"
        self.colorLightBlue = "#ADD8E6"
        self.colorBlue = "#0000ff"
        self.colorRed = "#ff0000"

        #file options
        self.file_opt = options = {}
        options['defaultextension'] = '.netsim'
        options['filetypes'] = [('all files', '.*'), ('text files', '.txt'), ('Simulation Files', '.netsim')]
        #options['initialdir'] = 'C:\\'
        options['initialfile'] = '.netsim'
        options['parent'] = self.root
        options['title'] = 'Save Simulation As...'

        #set up menu bar
        menubar = tk.Menu(self.root)
        filemenu = tk.Menu(menubar, tearoff=0)
        filemenu.add_command(label="Start Simulation", command=self.startSimulation)
        filemenu.add_command(label="Save Current Development Simulation", command=self.saveCurrentSimulation)
        filemenu.add_command(label="Load Development from File", command=self.loadSimulationFromFile)
        filemenu.add_separator()
        filemenu.add_command(label="Load Results from Evolutionary Algorithm",command=self.loadEvo)
        filemenu.add_separator()
        filemenu.add_command(label="Exit",command=self.root.destroy)
        menubar.add_cascade(label="File", menu=filemenu)
        speedmenu = tk.Menu(menubar, tearoff=0)
        speedmenu.add_command(label="1ms", command=lambda:self.setWriteInterval(1))
        speedmenu.add_command(label="25ms", command=lambda:self.setWriteInterval(25))
        speedmenu.add_command(label="50ms", command=lambda:self.setWriteInterval(50))
        speedmenu.add_command(label="100ms", command=lambda:self.setWriteInterval(100))
        speedmenu.add_command(label="1s", command=lambda:self.setWriteInterval(1000))
        speedmenu.add_command(label="Do not write")
        speedmenu.invoke(3)   #default write interval is 100
        editmenu = tk.Menu(menubar, tearoff=0)
        editmenu.add_command(label="Parameters",command = self.editParameters)
        editmenu.add_cascade(label="Write Interval", menu=speedmenu)
        menubar.add_cascade(label="Edit", menu=editmenu)
        self.root.config(menu=menubar)

        #Set up neuron graph and text log box and control bar
        self.neuronGraph = Graph(self.root, [75, 75, 475, 475], [-1.1, 1.1, -1.1, 1.1])
        self.neuronGraph.plotCircle((2, 2), (0, 0), self.colorWhite)
        self.neuronGraph.title("Development")
        self.neuronGraph.xlabel("XAXIS")
        self.neuronGraph.ylabel("YAXIS")
        self.neuronGraph.draw(self.canvas)

        #Set up World Parameter Options
        self.animNum_sv = tk.StringVar()
        self.animNum_sv.set(str(self.sP.getAnimNum(1)))
        self.foodNum_sv = tk.StringVar()
        self.foodNum_sv.set(str(self.sP.getFoodNum(1)))
        self.arenaSize_sv = tk.StringVar()
        self.arenaSize_sv.set(str(self.sP.getWorldSize(1)))
        title = tk.Label(self.root, text="Parameter Settings",font="bold",relief="ridge",padx=5,pady=5)
#.........这里部分代码省略.........
开发者ID:seatonj2,项目名称:AnimatSimulationMSU,代码行数:103,代码来源:DevelopmentWindow.py

示例2: __init__

# 需要导入模块: from Graph import Graph [as 别名]
# 或者: from Graph.Graph import xlabel [as 别名]

#.........这里部分代码省略.........
        worldmenu.add_radiobutton(label="World 2", variable = worldVar, command=lambda:self.setWorldNum(2))
        worldmenu.add_radiobutton(label="World 3", variable = worldVar, command=lambda:self.setWorldNum(3))
        worldmenu.add_radiobutton(label="World 4", variable = worldVar, command=lambda:self.setWorldNum(4))
        worldmenu.add_radiobutton(label="World 5", variable = worldVar, command=lambda:self.setWorldNum(5))
        speedmenu.invoke(self.sP.worldToRun-1)   #default write interval is 25
        editmenu = tk.Menu(self.menubar, tearoff=0)
        editmenu.add_cascade(label="Write Interval", menu=speedmenu)
        editmenu.add_cascade(label="World to Run", menu=worldmenu)
        editmenu.add_command(label="Parameters", command=self.showDevWin)
        self.menubar.add_cascade(label="Edit", menu=editmenu)
        trackmenu = tk.Menu(self.menubar, tearoff=0)
        trackmenu.add_checkbutton(label="Neural Firings", command = lambda:self.track(self.TRACK_NEURAL_FIRINGS))
        trackmenu.add_checkbutton(label="Energy", command = lambda:self.track(self.TRACK_ENERGY))
        trackmenu.add_checkbutton(label="Position", command = lambda:self.track(self.TRACK_POS))
        trackmenu.add_checkbutton(label="LFP", command = lambda:self.track(self.TRACK_LFP))
        trackmenu.invoke(0)
        trackmenu.invoke(1)
        trackmenu.invoke(2)
        trackmenu.invoke(3)
        self.menubar.add_cascade(label="Track", menu = trackmenu)
        viewMenu = tk.Menu(self.menubar, tearoff=0)
        viewMenu.add_command(label="Internal Variables",command=self.varViewer)
        viewMenu.add_command(label="Connection Viewer",command=self.connectionViewer)
        self.menubar.add_cascade(label="View",menu=viewMenu)
        debugMenu = tk.Menu(self.menubar, tearoff=0)
        debugMenu.add_command(label="Print S",command = self.printS)
        debugMenu.add_command(label="Print RL",command = self.printRL)
        self.menubar.add_cascade(label="Debug",menu=debugMenu)
        self.root.config(menu=self.menubar)

        #initialize the graphs and video control bar
        self.worldGraph = Graph(self.root, [100, 50, 500, 475], [-10, 10, -10, 10])
        self.worldGraph.title('World')
        self.worldGraph.xlabel('distance')
        self.neuron_graphs = {}
        self.neuron_box = TabBox(self.root, [600, 50, 1000, 475])
        self.videoBar = VideoBar(self.canvas, (100, 515, 500, 525), (0, 15000), self.timeClicked)

        #some images--will probably eventually go in respective classes (static state) - can remove 
        self.animatImage = Image.open("roomba.png")
        self.aImage = ImageTk.PhotoImage(self.animatImage)
        self.foodImage = Image.open("beer.png")
        self.fImage = ImageTk.PhotoImage(self.foodImage)
        playImage = ImageTk.PhotoImage(Image.open("play.png").resize((40, 40), Image.ANTIALIAS))
        pauseImage = ImageTk.PhotoImage(Image.open("pause.png").resize((40,40), Image.ANTIALIAS))
        stopImage = ImageTk.PhotoImage(Image.open("stop.png").resize((40,40), Image.ANTIALIAS))
        restartImage = ImageTk.PhotoImage(Image.open("restart.png").resize((40,40), Image.ANTIALIAS))
        step_fImage = ImageTk.PhotoImage(Image.open("step_f.png").resize((40,40), Image.ANTIALIAS))
        step_bImage = ImageTk.PhotoImage(Image.open("step_b.png").resize((40,40), Image.ANTIALIAS))
        continueImage = ImageTk.PhotoImage(Image.open("continue.png").resize((40,40), Image.ANTIALIAS))

        #video control buttons
        self.playButton = tk.Button(self.root, command = self.play, image = playImage, relief='sunken')
        self.playButton.place(x = 100,y=545)
        self.pauseButton = tk.Button(self.root, command = self.pause, image = pauseImage, relief='raised')
        self.pauseButton.place(x=155,y=545)
        # self.stopButton = tk.Button(self.root, command = self.stop, image = stopImage)
        # self.stopButton.place(x=320, y=545)
        self.restartButton = tk.Button(self.root, command = self.restart, text="Start New Simulation")
        self.restartButton.place(x=320, y=575)
        self.step_bButton = tk.Button(self.root, command = self.step_b, image = step_bImage)
        self.step_bButton.place(x=210,y=545)
        self.step_fButton = tk.Button(self.root, command = self.step_f, image = step_fImage)
        self.step_fButton.place(x=265, y=545)
        # self.continueButton = tk.Button(self.root, command = self.continue_, image = continueImage)
        # self.continueButton.place(x=430, y=545)
开发者ID:RyanAshbaugh,项目名称:AnimatSimulationMSU,代码行数:70,代码来源:GUIdriver.py


注:本文中的Graph.Graph.xlabel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。