I am trying to generate a plot for double integral using python, matplotlib. X and Y ranges are defined and Z is the double integral of X and Y.
import matplotlib.pyplot as plt
import numpy as np
import scipy
from scipy.integrate import dblquad
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
def function_I(x, y):
return np.sin(x)*np.cos(y/5)
#Make data
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
Z = scipy.integrate.dblquad(function_I, -5, 5, -5, 5)
# plot the surface
ax.plot_surface(X, Y, Z)
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()
line
ax.plot_surface(X, Y, Z)
gives
AttributeError: 'tuple' object has no attribute 'ndim'
some similar question provided solutions related to .shape and .reshape? Doesn't make a whole lot sense. Any comments appreciated!

scipy.integrate.dblquad. It returns more than an array. I found this page by copy/pasting "scipy.integrate.dblquad" into google and clicking on the first result: docs.scipy.org/doc/scipy/reference/generated/…typeof the 3 arguments,X,Y,Z. Before searching the web or asking us, you should have a clear idea of what each of the variables is.ax.plot_surface(X, Y, np.array(Z))ans, err = scipy.integrate.dblquad(function_I(X,Y), -5, 5, -5, 5)is indeed more accurate, still trying to figure this out...