Import matplotlib.pyplot AS PLT Import numpy AS NP X = np.linspace (-3,. 3, 50 ) Y1 = X + 2. 1 * # Figure. 1 plt.figure () plt.plot (X, Y1) # horizontal and vertical coordinates axis display range setting plt.xlim ((-. 1, 2 )) plt.ylim (( -2,. 3 )) # horizontal axis of ordinate name setting plt.xlabel ( " the I X-AM " ) plt.ylabel ( " the I AM the Y " ) # horizontal axis of ordinate redefined new_ticks np.linspace = (-1, 2,. 5) # the Return EVENLY Spaced in A over specified interval The Numbers. plt.yticks ([ plt.xticks (new_ticks)-2, -1.8, -1, 1.22, 3,], [r'$really\ bad$', r'$bad$', r'$normal$', r'$good$', r'$really\ good$',]) plt.show()
Axis movement #
Import matplotlib.pyplot AS PLT Import numpy AS NP X = np.linspace (-3,. 3, 50 ) Y1 = X + 2. 1 * # Figure. 1 plt.figure () plt.plot (X, Y1) # horizontal and vertical coordinates axis display range setting plt.xlim ((-. 1, 2 )) plt.ylim (( -2,. 3 )) # mobile gca axis = "GET Current axis" AX = plt.gca () ax.spines [ " right " ] .set_color ( " none " ) ax.spines [ " Top " ] .set_color ( " none " ) ax.xaxis.set_ticks_position("bottom") ax.yaxis.set_ticks_position("left") ax.spines["bottom"].set_position(("data", 0)) #Set the X and Y coordinates of the sprite simultaneously ax.spines["left"].set_position(("data", 0)) plt.show()