python - Matplotlib 流图不同颜色
问题描述
我打算用不同的颜色制作一个流线图,用二维数组表示不同点的强度。u,v 代表不同点的风分量。
代码:
x = np.linspace(71.679886,100.43091,299) ##longitude
y = np.linspace(10.64794,31.228256,231) ##latitude
level = [0,5]
for t in level: ##t is level in output
U = u[t,:,:]
V = v[t,:,:]
f = X[t,:,:]
SPD = sqrt(u**2+v**2)
print(SPD)
pyplot.streamplot(x,y,u,v,density=5,arrowsize=1,integration_direction='forward',color=SPD,cmap="autumn",linewidth=2)
pyplot.show()
链接显示,可以通过使用 指定 2D 数组来制作此类图color
,但我收到错误:ValueError: RGBA sequence should have length 3 or 4
如果我使用 2D 数组,则color=SPD
. 请帮忙。
解决方案
推荐阅读
- c++ - 如何使用获取-释放内存顺序模型实现简单的自定义锁?
- python - 无法读取网络摄像头流:VideoCapture
- python - 即使字符串颠倒,也计算列表中字符串的出现次数
- flask - 如何查找变量是否包含字符串列表中的字符串
- swift - 上传图片二进制目标c
- flutter - 在flutter web中加载html内容?
- javascript - 使用 JavaScript 中的构建器模式方法在 dom 中构建标签
- vue.js - 如何在 Vue 3 中获取数据?
- javascript - 如何重新启动 jQuery Ticker
- python - python:列表索引超出范围