使用matplotlib绘制曲线图

绘制自己的曲线图

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0,10,20)

y1 = x**2.0

y2 = x**1.5

'''
plt.plot(Abscissa, ordinate,"bo-",linewidth="",markersize="",label="")
"bo-":The shape of the point of the curve
linewidth:The distance from the point on the curve
markersize:The size of the point on the curve
label:Description of the curve
'''
plt.plot(x,y1,"bo-",linewidth=2,markersize=12,label="First")
plt.plot(x,y2,"gs-",linewidth=2,markersize=12,label="Sceond")

#Label corresponding to horizontal and vertical coordinates
plt.xlabel("X")
plt.xlabel("Y")


plt.axis([-0.5,10.5,-5,105])                #plt.axis([xmin,xmax,ymin,ymax])

'''plt.legend(loc=""):The location of the description of the curve
	loc=
	upper right
	upper left
	lower left
	lower right
	right
	center left
	center right
	lower center
	upper center
	center
'''
plt.legend(loc="upper left")

plt.show()

使用matplotlib绘制曲线图_第1张图片


("If you want the rainbow, you have to deal with the rain." --《The Fault in Our Stars》)

你可能感兴趣的:(Python3.7)