import matplotlib.pyplot as plt # 线段中两点的坐标如示例中 # x=[[1,1],...] y=[[3.5,0],...] # 即标了点(1,3,5)与点(1,0),之后使用plot()函数连接两点 x = [[1, 1], [2, 2],[3, 3], [4, 4]] y = [[3.5, 0], [0.5, 1],[2.5, 0], [0, 15.5]] for i in range(len(x)): plt.scatter(x[i], y[i], color='black', s=5) plt.annotate("y="+str(y[i][0]), xy=(x[i][0], y[i][0]), xytext=(+15, -15), textcoords='offset points', fontsize=10,arrowprops=dict(arrowstyle='->', connectionstyle='arc3,rad=.2')) plt.annotate("y="+str(y[i][1]), xy=(x[i][1], y[i][1]), xytext=(+15, -15), textcoords='offset points', fontsize=10,arrowprops=dict(arrowstyle='->', connectionstyle='arc3,rad=.2')) plt.plot(x[i], y[i], label='sin') plt.xlim(0,5) plt.ylim(0,16) plt.show()