The code below draws X,Y axes in a graphics window. Add tick marks to each axis.
Use graphics.py. Click HERE for more information. (download, install, documentation, etc.)
#! /usr/bin/python3 # =================================================================== # draw X,Y axes # =================================================================== from graphics import * # ------------------------------------------------------------------- # ---- function: draw x,y axes # ------------------------------------------------------------------- def draw_xy_axes(win,linewidth=1,linecolor="black"): wx = win.width # window width wy = win.height # window height wcx = round(wx/2.0) # window center X wcy = round(wy/2.0) # window center Y # ---- X axis xl = Line(Point(0,wcy),Point(wx-1,wcy)) xl.setWidth(linewidth) xl.setFill(linecolor) xl.draw(win) # ---- Y axis yl = Line(Point(wcx,0),Point(wcx,wy-1)) yl.setWidth(linewidth) yl.setFill(linecolor) yl.draw(win) # ------------------------------------------------------------------- # ---- main # ------------------------------------------------------------------- if __name__ == '__main__': win = GraphWin("X,Y Axes", 801, 801) win.setBackground("white") draw_xy_axes(win) win.getMouse() # pause for click in window win.close()