. 1 Import matplotlib.pyplot AS PLT 2 Import numpy AS NP . 3 . 4 X = np.linspace (-3,. 3, 50 ) . 5 Y1 = X + 2 *. 1 . 6 . 7 # Figure. 1 . 8 plt.figure () . 9 plt.plot (X, Y1, as linewidth = 10, = ZOrder. 1 ) 10 . 11 12 is # cross-ordinate axis shows the range setting 13 is plt.xlim ((- 2, 2 )) 14 plt.ylim ((- 10, 10 )) 15 16 # mobile gca axis = "GET Current axis" . 17 AX = plt.gca () 18 is ax.spines [ "right"].set_color("none") 19 ax.spines["top"].set_color("none") 20 ax.xaxis.set_ticks_position("bottom") 21 ax.yaxis.set_ticks_position("left") 22 ax.spines["bottom"].set_position(("data", 0)) #Set the X and Y coordinates of the sprite simultaneously 23 ax.spines["left" ] .Set_position (( " Data " , 0)) 24 25 # case when the coordinate value data overlay appears: 26 is 27 # Method a: direct plt.plot (x, y1, linewidth = 10) modified to plt.plot (x, y1, linewidth = 10 , zorder = 1) to 28 # method two: each of coordinate values taken out, as the correlation process on the data so as to cover, in order to achieve visualization 29 for label in ax.get_xticklabels () + ax.get_yticklabels (): 30 label.set_fontsize (10 ) 31 is label.set_zorder (. 1 ) 32 label.set_bbox (dict (facecolor = " White " , edgecolor = " None ", alpha = 0.1)) 33 34 plt.show()
. 1 Import matplotlib.pyplot AS PLT 2 Import numpy AS NP . 3 . 4 n-= 1024 . 5 X-np.random.normal = (0,. 1 , n-) . 6 the Y np.random.normal = (0,. 1 , n-) . 7 T = np.arctan2 (the Y, X-) . 8 . 9 # on scatter parameters related description, with reference to Bowen https://blog.csdn.net/qiu931110/article/details/68130199 10 plt.scatter (X-, the Y, S = 75, T = C, Alpha = 0.5 ) . 11 12 is plt.xlim ((- for 1.5, +1.5 )) 13 is plt.ylim ((- for 1.5, +1.5 )) 14 15 plt.show ()
. 1 Import matplotlib.pyplot AS PLT 2 Import numpy AS NP . 3 . 4 n-= 1024 . 5 X-np.random.normal = (0,. 1 , n-) . 6 the Y np.random.normal = (0,. 1 , n-) . 7 T = np.arctan2 (the Y, X-) . 8 . 9 # on scatter parameters related description, with reference to Bowen https://blog.csdn.net/qiu931110/article/details/68130199 10 plt.scatter (X-, the Y, S = 75, T = C, Alpha = 0.5 ) . 11 plt.xlim ((- for 1.5, +1.5 )) 12 is plt.ylim ((- for 1.5, +1.5 )) 13 is 14 # coordinate scale hide 15 plt.xticks (()) 16 plt.yticks(()) 17 18 plt.show()
. 1 Import matplotlib.pyplot AS PLT 2 Import numpy AS NP . 3 . 4 n-= 12 is . 5 X-= np.arange (n-) . 6 Yl = (. 1 - X-/ a float (n-)) * np.random.uniform (0.5, 1.0 , n-) . 7 Y2 = (. 1 - X-/ a float (n-)) * np.random.uniform (0.5, 1.0 , n-) . 8 . 9 # plt.bar () of parameters, reference Bowen https://www.cnblogs.com /shine-rainbow/p/10742952.html 10 # draw bar . 11 plt.bar (X-, + Yl, facecolor = " # 9999FF " , edgecolor = " White " ) 12 isplt.bar (X-, -Y2, facecolor = " # FF9999 " , edgecolor = " White " ) 13 is 14 # text () of parameters 15 # ################## ## 16 # (X, Y, String, fontSize = 15, VerticalAlignment = "Top", HorizontalAlignment = "right") plt.text . 17 # parameters: 18 is # X, Y: represents a value on the coordinate values . 19 # String: explanatory text 20 is # fontSize: the font size represents 21 is # VerticalAlignment: vertical alignment parameters: [ 'Center' | 'Top' | 'bottom' | 'Baseline'] 22 is # horizontalalignment:水平对齐方式 ,参数:[ ‘center’ | ‘right’ | ‘left’ ] 23 24 for x,y in zip(X, Y1): 25 plt.text(x, y, "%.2f"%y, ha = "center", va = "bottom") 26 27 for x,y in zip(X, -Y2): 28 plt.text(x, y, "%.2f"%y, ha = "center", va = "top") 29 30 plt.xticks(()) 31 plt.yticks (()) 32 33 plt.show ()