TypeError: Ungültige Abmessungen für Bilddaten beim Zeichnen eines Arrays mit imshow ()

Für den folgenden Code

# Numerical operation
SN_map_final = (new_SN_map - mean_SN) / sigma_SN  

# Plot figure
fig12 = plt.figure(12)
fig_SN_final = plt.imshow(SN_map_final, interpolation='nearest')
plt.colorbar()

fig12 = plt.savefig(outname12)

mitnew_SN_map ist ein 1D Array undmean_SN undsigma_SN Da es sich um Konstanten handelt, wird der folgende Fehler angezeigt.

Traceback (most recent call last):
  File "c:\Users\Valentin\Desktop\Stage M2\density_map_simple.py", line 546, in <module>
    fig_SN_final = plt.imshow(SN_map_final, interpolation='nearest')
  File "c:\users\valentin\appdata\local\enthought\canopy\user\lib\site-packages\matplotlib\pyplot.py", line 3022, in imshow
    **kwargs)
  File "c:\users\valentin\appdata\local\enthought\canopy\user\lib\site-packages\matplotlib\__init__.py", line 1812, in inner
    return func(ax, *args, **kwargs)
  File "c:\users\valentin\appdata\local\enthought\canopy\user\lib\site-packages\matplotlib\axes\_axes.py", line 4947, in imshow
    im.set_data(X)
  File "c:\users\valentin\appdata\local\enthought\canopy\user\lib\site-packages\matplotlib\image.py", line 453, in set_data
    raise TypeError("Invalid dimensions for image data")
TypeError: Invalid dimensions for image data

Was ist die Quelle dieses Fehlers? Ich dachte, meine numerischen Operationen wären erlaubt.

Antworten auf die Frage(2)

Ihre Antwort auf die Frage