私はPythonが初めてです。gridx、gridy、および V のすべてのサイズ 401x121 に、matplotlib の pcolor を使用しようとしています。機能は次のとおりです。
def plotSpatialKM(V,gridx,gridy,step_h):
plt.figure(figsize=(18,8), dpi=80, facecolor='white')
plt.pcolor(gridx,gridy,V)
plt.colorbar()
plt.xlim(gridx.min(), gridx.max())
plt.ylim(gridy.min(), gridy.max())
plt.xlabel('x/h',fontsize=FONTSIZE)
plt.ylabel('y/h',fontsize=FONTSIZE)
plt.xticks(fontsize=FONTSIZE)
plt.yticks(fontsize=FONTSIZE)
plt.show()
return(1)
しかし、常に次のエラーが発生します。
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1410, in __call__
return self.func(*args)
File "C:\Python27\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 276, in resize
self.show()
File "C:\Python27\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 348, in draw
FigureCanvasAgg.draw(self)
File "C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py", line 439, in draw
self.figure.draw(self.renderer)
File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 54, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 999, in draw
func(*args)
File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 54, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 2086, in draw
a.draw(renderer)
File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 54, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\Python27\lib\site-packages\matplotlib\collections.py", line 755, in draw
return Collection.draw(self, renderer)
File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 54, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\Python27\lib\site-packages\matplotlib\collections.py", line 244, in draw
self.update_scalarmappable()
File "C:\Python27\lib\site-packages\matplotlib\collections.py", line 609, in update_scalarmappable
raise ValueError('Collections can only map rank 1 arrays')
ValueError: Collections can only map rank 1 arrays
助けてください!