Python 3.x matplotlib.pyplot imshow()现在显示纯蓝色,不再显示颜色渲染?

Python 3.x matplotlib.pyplot imshow()现在显示纯蓝色,不再显示颜色渲染?,python-3.x,matplotlib,Python 3.x,Matplotlib,除了我先前提出的问题之外,这里还有一个很有帮助的问题 在对一些参数进行了一些修改之后,spyder现在始终显示一个空白的蓝色输出。真让人费解!! 我已经强制将数据类型设置为uint8(我读到这篇文章是关于一个相关的问题,这可能是原因),但没有用 编辑:(感谢快速响应)以下是相关代码(来自一个更大的程序,用于模拟通过方形光圈的衍射): 情节是这样的: 为此: 提前感谢。在不知道生成这两幅图像的代码的情况下,我只能说,第二幅图像似乎是第一幅图像的剪切部分,位于没有数据或数据接近或等于最小值的区域

除了我先前提出的问题之外,这里还有一个很有帮助的问题 在对一些参数进行了一些修改之后,spyder现在始终显示一个空白的蓝色输出。真让人费解!! 我已经强制将数据类型设置为uint8(我读到这篇文章是关于一个相关的问题,这可能是原因),但没有用

编辑:(感谢快速响应)以下是相关代码(来自一个更大的程序,用于模拟通过方形光圈的衍射):

情节是这样的:

为此:

提前感谢。

在不知道生成这两幅图像的代码的情况下,我只能说,第二幅图像似乎是第一幅图像的剪切部分,位于没有数据或数据接近或等于最小值的区域


您的实际数据是什么样的?你能提供代码来生成你的结果吗。提供一个刚刚编辑好的“我的问题”以包含相关代码是很有帮助的。
import numpy as np
import matplotlib.pyplot as plt

def expo(x,y,z,xp,yp,k):
    """
    Function of the integrand in Eq. 5
    """
    return np.exp((1j*k/(2*z))*(((x-xp)**2) + ((y-yp)**2))) 

def square_2dsimpson_eval(a,b,n):
    simp_eval = np.zeros((n+1,n+1))
    deltap = (b-a)/n
    xp = 0
    yp = 0
    w = np.zeros((n+1,n+1))
    x=0
    y=0
    for h in range(n+1):    #the first two for loops produce the 2d Simpson matrix of coeffecients
        if h == 0 or h==n:
            w[0,h] = 1

        elif h%2 != 0:
            w[0,h]=4

        elif h%2 == 0:
            w[0,h]=2

    for g in range(n+1):
        if g ==0 or g==n:
            w[g,0]=1

        elif g%2 != 0:
            w[g,0]=4             

        elif g%2 == 0:
            w[g,0]=2

    for h in range(1,n+1):
        for g in range(1,n+1):
            w[h,g]=w[0,h]*w[g,0]

    for h in range(0,n+1):
        xp = h*deltap
        for g in range(0,n+1):
            yp = g*deltap
            simp_eval[h,g] = expo(x,y,z,xp,yp,k) #the integrand

    return (k/(2*np.pi*z))*((deltap**2)/9)*(np.sum(simp_eval*w))

n = 3.3

        #this loop checks that user's N is even as required for Simpson's rule
        while n % 2 != 0:
            n = int(input("Type an even N value: "))
            if n % 2 == 0:
                break
            else:
                print("n must be even you noob!")
        lam=float(input("Type light wavelength in mm: "))
        k=(2*np.pi)/lam
        z=float(input("Type screen distance, z in mm: "))
        rho=float(input("Type rho in mm: "))

        delta = 2/n
        intensity = np.zeros((n+1,n+1),dtype='uint8')
        for i in range(n+1):
            x=-1+(i*delta)
            for j in range(n+1):
                y =-1+(j*delta)
                intensity[i,j] = (abs(square_2dsimpson_eval(-rho/2,rho/2,n)))**2  
        print(intensity.dtype)
        plt.imshow(intensity)
        plt.show()