import os
import matplotlib.pyplot as plt
import numpy as np
import scipy.interpolate
#from mpl_toolkits.mplot3d import Axes3D
os.chdir(r'D:\projects\wordpress\ex58')
os.getcwd()
x=y=np.arange(10)
f=(lambda i,j: np.sin(i)*np.cos(j)) # function to interpolate
A=np.fromfunction(f, (10,10)) # generate samples
spline=scipy.interpolate.RectBivariateSpline(x,y,A)
fig=plt.figure()
subplot=fig.add_subplot(111,projection='3d')
xx=np.mgrid[0:9:100j, 0:9:100j] # larger grid for plotting
A=spline(np.linspace(0,9,100), np.linspace(0,9,100))
subplot.plot_surface(xx[0],xx[1],A)
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("example58.png", dpi=100)
plt.show()
plt.close()

example58

Discover more from Tips and Hints for Aerospace Engineers

Subscribe now to keep reading and get access to the full archive.

Continue reading