我正在尝试使用matplotlib在墨西哥湾地图上绘制温度梯度。我将lat,long和temp定义为x,y,z。理想情况下,我希望每个坐标的点都在一个带有彩色温度梯度的地图上绘制。这是我使用的代码(为简单起见,我缩短了数据集):
poslat=[29.50736,24.50824,28.99417,27.0074,27.00416,26.51342,26.00732,25.99168,26.49908]
poslon=[-86.50889,-84.49289,-87.00188,-89.99935,-91.00347,-90.99752,-91.50267,-92.00522]
postemp = [24.73,24.753,24.753,24.756,24.778,24.859,24.859,24.859,24.867,24.867,24.867,25.224]
x,y,z=m(poslon,poslat,postemp)
m.plot(x,y,'ro',markersize=5)
plt.contour(x,y,z)
plt.colorbar()
plt.show()`
以下是我得到的错误:
Warning (from warnings module):
File "/Users/sydneyharned/anaconda3/lib/python3.6/site-packages/mpl_toolkits/basemap/__init__.py", line 1711
if limb is not ax.axesPatch:
MatplotlibDeprecationWarning: The axesPatch function was deprecated in version 2.1. Use Axes.patch instead.
Traceback (most recent call last):
File "/Users/sydneyharned/praccompproject.py", line 31, in <module>
x,y,z=m(poslon,poslat,postemp)
ValueError: not enough values to unpack (expected 3, got 2)
我似乎无法弄清楚我失踪的价值..有谁知道如何修复其中任何一个?任何帮助表示赞赏。
答案 0 :(得分:0)
你应该检查功能“m”的返回。
正如调试信息描述的那样,“m”只返回两个值,而在使用它时,它需要三个。
(x,y,z) = m(poslon,poslat,postemp)
# should return (x,y) maybe