Generate an image plot of the sinc function in the Cartesian plane, $\mathrm{sinc}(r) = \sin r / r$ where $r = \sqrt{x^2+y^2}$.
The following code uses np.hypot
and np.sinc
to calculate the function, and plot_surface
with the summer
colormap to produce the plot:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.cm as cm
x, y = np.linspace(-10,10,400), np.linspace(-10,10,400)
X, Y = np.meshgrid(x, y)
f = np.sinc(np.hypot(X, Y))
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(X, Y, f, rstride=5, cstride=5, cmap=cm.summer)
plt.show()