Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3-使用Axes3D.plot\u线框绘制三维图形_Python_Matplotlib_Plot - Fatal编程技术网

Python 3-使用Axes3D.plot\u线框绘制三维图形

Python 3-使用Axes3D.plot\u线框绘制三维图形,python,matplotlib,plot,Python,Matplotlib,Plot,使用matplotlib(Axes3D)绘制三维打印时遇到一些问题 下面的代码调用了我定义的函数“solver” 以下是解算器函数: def solver(r, t, D, C_init, a): """ Function to solve the equation of diffusion for a cylinder of radius a. ------- Arguments : r - radius at which we evaluate C

使用matplotlib(Axes3D)绘制三维打印时遇到一些问题

下面的代码调用了我定义的函数“solver”

以下是解算器函数:

def solver(r, t, D, C_init, a):
    """
    Function to solve the equation of diffusion for a cylinder of radius a.

    -------

    Arguments :
    r - radius at which we evaluate C (concentraion in particles)
    t - time at which we evaluate C (concentration in particles)
    D - diffusion coefficient
    C_init - initial concentration in particles
    a - initial radius of the cylinder(or sphere)

    --------

    Returns :

    C(r,t) - Concentration of particles at radius r, and instant t
    """
    integral, err = quad(function_to_integrate, 0, a, (r, t, D))
    return C_init/(2*D*t)*np.exp(-r**2/(4*D*t)) * integral
要集成的函数是super basic,下面是代码:

def function_to_integrate(rp, r, t, D):
    """
    Function used solely to be integrated using scipy.integrate.quad(). Used in solver function.

    --------

    Arguments :
    rp - integrate variable
    r - radius we evaluate the function at
    t - time we evaluate the function at
    D - diffusion coefficient

    ---------

    Returns :

    exp(-rp²/4Dt)I0(r*rp/2Dt)rp
    """

    return np.exp(-rp**2/(4*D*t))*np.i0([float(r*rp/(2*D*t))])*rp
当我尝试绘制3D图形时,python会产生: TypeError:只有长度为1的数组才能转换为Python标量

表示在解算器函数返回时发生。我不明白为什么会出现这个错误以及如何修复它

def function_to_integrate(rp, r, t, D):
    """
    Function used solely to be integrated using scipy.integrate.quad(). Used in solver function.

    --------

    Arguments :
    rp - integrate variable
    r - radius we evaluate the function at
    t - time we evaluate the function at
    D - diffusion coefficient

    ---------

    Returns :

    exp(-rp²/4Dt)I0(r*rp/2Dt)rp
    """

    return np.exp(-rp**2/(4*D*t))*np.i0([float(r*rp/(2*D*t))])*rp