# -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt x=np.array([0,2,3],float) y=np.array([7,11,28],float) #[-1]:means use the last value of the series.[2] can also be used. xplt=np.linspace(x[0],x[-1],13)#linspace: Returns evenly spaced numbers print(xplt) #(between the start and end points) at the specified range. yplt=np.array([],float) #Calculated values will be added. Variable limits are used. print(yplt) for xp in xplt: yp=0 #Reference point. When -1 or +1 is used, #the graph is moved on the y axis. for xi,yi in zip(x,y): yp +=yi*np.prod((xp-x[x !=xi])/(xi-x [x !=xi])) yplt= np.append(yplt,yp) #is used to determine the values and their #position in the graph. plt.plot(x,y,'bs',xplt,yplt,'r--') #bs: (b:blue)color and (s:square)shape of the spot plt.xlabel('x') #r--: (r:red), (--)line shape.(.)(-)... plt.ylabel('y') plt.grid() plt.show()