# -*- coding: utf-8 -*- """ Created on Tue Nov 04 21:22:29 2014 @author: dell """ import numpy as np import matplotlib.pyplot as plt x, y = np.meshgrid(np.linspace(-2,2,21), np.linspace(-2,2,21)) z = x * np.exp(-x**2 - y**2) u, v = np.gradient(z, .2, .2) fig, ax = plt.subplots() ax.quiver(x, y, u, v) plt.show()
-
Quiver
2019-06-25 17:21:53Quiver快速入门 程序员专用笔记 Quiver -
quiver
2014-11-04 21:25:00# -*- coding: utf-8 -*- """ Created on Tue Nov 04 21:22:29 2014 @author: dell """ ...ax.quiver(x, y, u, v) plt.show() 转载于:https://www.cnblogs.com/hluo/p/4074812.html转载于:https://www.cnblogs.com/hluo/p/4074812.html
-
Crossbow Quiver
2020-12-08 23:20:48<div><p>If you fill the a quiver with an arrow, it will create a full new quiver not combatible with your crossbow you just have shot. Same trying to make new quiver with that arrow you have found or ... -
Quiver Autoloading
2021-01-12 01:57:39[✔] More arrows than quiver holds (fill quiver, rest in inv) ........[✔] Autopickup ........[✔] Regular pickup [✔] Multiple non-full quivers (rest in inv) ........[✔] Autopickup ........[✔] ... -
Quiver305 MAS
2017-05-31 15:10:52Quiver305是Mac系统下的日记软件,个人感觉很好用。 -
cleanup quiver function
2021-01-12 01:40:45<em>Player</em> calls <code>player::add_ammo_to_worn_quiver, and each <em>quiver</em> calls <code>item::quiver_store_arrow</code> to store arrows. <p>Maybe it is more understandable. <p><strong>... -
matlab开发-quiver3d
2019-08-27 04:22:41matlab开发-quiver3d。该函数改进了Quiver3可视化三维矢量场的技术。 -
python matplotlib quiver——画箭头、风场
2018-12-21 10:29:02如果想用风羽画风场,请看另一篇python画风羽及风羽定义 目录 用像素点坐标画图 用经纬度坐标画图(推荐) ...箭头关键的一个参数是长度,长度可以通过参数scale来设置,如果你多次使用quiver(),只要保证...如果想用风羽画风场,请看另一篇python画风羽及风羽定义
目录
PS:三维箭头可参考:
https://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html#quiver
另有Stack Overflow上的问题可能有帮助:https://stackoverflow.com/questions/7130474/3d-vector-field-in-matplotlib
https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.quiver
上面是官方文档的链接
用像素点坐标画图
箭头关键的一个参数是长度,长度可以通过参数scale来设置,如果你多次使用quiver(),只要保证参数scale一致,那么箭头长度就会与风速
的值成正比,可按照下面我贴出的代码那样设置参数。建议scale设置成30-50,100之内也都还可以。箭头宽度可以通过width=0.005开始设置。箭头颜色可以通过传入颜色列表来控制。
Axes.
quiver
(*args, data=None, **kw)用于画二维的箭头
调用quivers有以下几种形式(signatures):
quiver(U, V, **kw) quiver(U, V, C, **kw) quiver(X, Y, U, V, **kw) quiver(X, Y, U, V, C, **kw)
U、V是箭头数据(data),X、Y是箭头的位置,C是箭头的颜色。这些参数可以是一维或二维的数组或序列。
如果X、Y不存在(absent),他们将作为均匀网格被生成。如果U和V是2维的数组,X和Y是1维数组,并且len(X)和len(Y)与U的列(column)和行(row)纬度相匹配(match),那么X和Y将使用numpy.meshgrid()——用于产生一个矩阵,具体可参考:meshgrid使用方法——进行扩展。
默认设置会自动将箭头的长度缩放到合理的大小。要改变箭头的长度请参看 scale 和scale_units两个关键字参数(kwargs:关键字参数,参看文章最后有关键字参数与可变参数的区别)
默认值给出一个稍微后掠(swept-back)的箭头;若要使箭头头部呈三角状,则要确保headaxislength与headlength相同。若要使箭头更尖锐(more pointed),则应减小headwidth或者增大headlength和headaxislength。若要使箭头头部相对于箭杆(shaft)更小一些,则应将所有头部参数都减小(scale down)。你最好不要单独留下minshaft(You will probably do best to leave minshaft alone.)
线宽和边缘颜色可以用于自定义箭头轮廓(outlines)。
参数
X: 1D or 2D array, sequence, optional
1维或2维数组,序列(sequence),可自选(optional)
箭头位置的x坐标
Y:1D or 2D array, sequence, optional
1维或2维数组,序列,可自选
箭头位置的y坐标
U: 1D or 2D array or masked array, sequence
1维或2维数组或掩码数组(参看masked array https://blog.csdn.net/liukai2918/article/details/78419302),序列
箭头矢量的x分量
V:1D or 2D array or masked array, sequence
1维或2维数组或掩码数组,序列
箭头矢量的y分量
C: 1D or 2D array, sequence, optional
1维或2维数组,序列(sequence),可自选
箭头颜色
units(单位): [ 'width' | 'height' | 'dots' | 'inches' | 'x' | 'y' | 'xy' ]
箭头尺寸(除长度外)以此单位的倍数计算——即是说选定单位后,箭头尺寸即是此单位的倍数
‘width’或’height’:轴(axis)的宽度或高度
‘dots’或’inches’:像素或英寸,基于图的dpi
‘x’, ‘y’或‘xy’:分别是X、Y或X2+Y2
的数据单位(data units)
箭头依单位不同而不同。对于’x’或’y’,箭头会随着其一的增大(zoom in)而增大;对于其他单位,箭头的大小与缩放状态(zoom state)无关。对于’width’或’height’,当窗口重置时,箭头的大小会随着轴(axes)的宽度和高度的增大而增大;低于同意’dots’或’inches’。重置不会改变箭头。
angles: [‘uv’ | ‘xy’], array, 可自选
用于决定箭头角度的方法,默认是’uv’
‘uv’:箭头的纵横比(axis aspect ratio)为1,所以若U*==*V,则绘图上箭头的方向与水平轴逆时针呈45度(正向右)。
‘xy’: 箭头从(x,y)指向(x + u,y + v)。例如,使用它来绘制渐变场(gradient field)。
或者,可以将任意角度指定为以水平轴逆时针方向的度数值的数组。
注意:反转数据轴将相应地仅使用angles='xy'反转箭头。
scale : None, float, optional
每个箭头长度单位的数据单位数量,例如,每个绘图宽度m / s;参数scale越小箭头越长。默认是None
若是None,一个简单的自动缩放算法将被采用,基于平均矢量长度和适量的数量。箭头长度单位由scale_units参数给出。
scale_units : [ 'width' | 'height' | 'dots' | 'inches' | 'x' | 'y' | 'xy' ], None, optional
如果关键字参数scale是None,那么箭头长度单位默认是None
例如:scale_units是’inches’,scale是2.0,(u,v)=(1,0),那么矢量将会是0.5英寸长。
如果scale_units是’width/height’,那么矢量长度是轴’width/height’的半长
如果scale_units是’x’那么矢量是x轴单位的0.5倍。要在x-y平面上画矢量,使得u和v与x和y有相同的单位,则应另angles=’xy’, scale_units’xy’, scale=1.
width : scalar(标量), optional
箭杆(shaft)的宽度,以箭头单位衡量。默认是由以上单位的选择和矢量数量来决定。常用的初始值是0.005倍的画的宽度(width of the plot)
headwidth : scalar, optional
头部宽度相对于箭杆宽度的倍数,默认是3倍
headlength : scalar, optional
轴交叉处的头部长度,默认是4.5
minshaft : scalar, optional
箭头比例的长度,以头部长度为单位。不要将其设置为小于1,否则小箭头看起来会很糟糕
minlength : scalar, optional
最小长度为轴宽的倍数;如果箭头长度小于此值,则绘制该直径的点(六边形)。默认值为1
pivot : [ 'tail' | 'mid' | 'middle' | 'tip' ], optional
箭头在网格点上的部分;箭头围绕这一点旋转,因此称为枢轴。
color : [ color | color sequence ], optional
这是PolyCollection facecolor kwarg的同义词。如果设置了C,颜色就没有效果。
quiver(*args, **kw)
import matplotlib.pyplot as plt import math from mpl_toolkits.basemap import Basemap from pylab import * import numpy as np mpl.rcParams['font.sans-serif'] = ['SimHei'] for i in range(1,3): plt.subplot(2, 1, i) ax = plt.gca() wind = [x for x in range(1,9)] # angle = [45*x for x in range(0,8)] # lon = list(np.linspace(113.8, 114.6, 8)) lat = list(np.linspace(22.4, 22.85, 8)) # wind = [2]*8 angle = [90]*8 # 为方便比较长度,箭头方向设置成一样 lon = [114.27] * 8 # 为方便比较长度,箭头经度设置成一样 # 指定地图范围、投影方式(projection)等 area_thresh是与湖泊等在地图上显示相关的参数 m = Basemap(llcrnrlon=113.7, llcrnrlat=22.35, urcrnrlon=114.7, urcrnrlat=22.9,\ rsphere=(6378137.00,6356752.3142),\ resolution='l', area_thresh=1000., projection='lcc', lat_1=22.5, lat_0=22.5, lon_0=114,ax=ax) lon, lat = m(*(lon, lat)) # 一系列的U、V ver = [-spd*math.sin(math.radians(agl)) for spd,agl in zip(wind, angle)] # U分量 hriz = [-spd*math.cos(math.radians(agl)) for spd,agl in zip(wind, angle)] # V分量 print(ver, '\n', hriz) ax=plt.gca() #下面两行是读取地图中的shape文件,即轮廓图 # m.readshapefile(r'G:\深圳季风研究\gadm36_HKG_shp\gadm36_HKG_0', 'states',color='grey') #HongKong # # m.readshapefile(r'G:\深圳季风研究\gadm36_CHN_shp\gadm36_CHN_3', 'states',color='grey') #Mainland in given lon and lat # m.readshapefile(r'G:\深圳季风研究\gadm36_sz_shp\Bon_data\xzq_sz_pop', 'states', color='grey') m.scatter(lon, lat, s=2, color='goldenrod', marker="o") #根据经纬度,画出对应站点位置 ax.set_title('风场') # ax.quiver(lon, lat, ver, hriz, units='width', scale=2, width=0.01, color='deepskyblue') ax.quiver(lon, lat, ver, hriz, color='deepskyblue', width=0.005, scale=30) for i, wspd in enumerate(wind): ax.annotate(str(wspd), (lon[i], lat[i])) # 在图上添加一些文字信息 plt.text(0.6,0.9, r'$mean: $'+str(18) + '°', color='forestgreen',transform=ax.transAxes, fontweight='extra bold') plt.text(1.02,0.6, r'$S: $' + str(18) + '%', color='forestgreen',transform=ax.transAxes, fontweight='heavy') plt.text(1.02,0.4, r'$N: $', color='forestgreen',transform=ax.transAxes, fontweight=100) # 画经纬度网格 m.drawmeridians([114.0,114.4], labels=[1,0,0,1]) # meridian:子午线,经线 arange指明范围和间隔 m.drawparallels(np.arange(15, 30, 0.3), labels=[1,0,0,0]) # 画纬度平行线 # 比例尺长度的U、V值和位置 q_lon, q_lat = m(*(114.27, 22.75)) spd = 2 angle_all = 90 ver_all = -spd*math.sin(math.radians(angle_all)) hriz_all = -spd*math.cos(math.radians(angle_all)) # ax.quiver(q_lon, q_lat, ver_all, hriz_all, color='g', pivot='mid') # mid是旋转枢纽在中间,默认在尾部 ax.quiver(q_lon, q_lat, ver_all, hriz_all, color='g', scale=30) # 画比例尺 plt.text(0.82,0.1, r'$scale:$', color='r',transform=ax.transAxes, fontweight=100, fontsize=8) plt.text(0.82,0.03, r'$2m/s$', color='r',transform=ax.transAxes, fontweight=100, fontsize=8) plt.quiver(95000, 3000, 3, hriz_all, color='r', width=0.005, scale=50) print(-ver_all, hriz_all) # 这一段与画箭头不相干,可忽略注释掉 画散点,为不同散点设置不同颜色 # Colors=('#DDDDFF','#7D7DFF','#0000C6','#000079','#CEFFCE','#28FF28','#007500','#FFFF93') # sc = plt.scatter(lon, lat, s=100, color=Colors, marker="o") #根据经纬度,画出对应站点位置 # for i,txt in enumerate(Colors): # ax.annotate(txt,(lon[i],lat[i]), fontsize=5) plt.show()
下面是代码运行结果:
未读入shape文件的结果:
读入了shape文件的结果
quiver(*args, **kw)
*args, **kw分别是可变参数和关键字参数,参考此文总结如下:
用经纬度坐标画图(推荐)
下面是和上面相同功能的代码,区别在于前者画图时,将坐标转换成了像素点坐标,而下面的代码则直接传入经纬度坐标(这个方法只对basemap对象有效,使用经纬度坐标时应传参数latlon=True):
import matplotlib.pyplot as plt import math from mpl_toolkits.basemap import Basemap from pylab import * import numpy as np mpl.rcParams['font.sans-serif'] = ['SimHei'] for i in range(1,3): plt.subplot(2, 1, i) ax = plt.gca() wind = [x for x in range(1,9)] # angle = [45*x for x in range(0,8)] # lon = list(np.linspace(113.8, 114.6, 8)) lat = list(np.linspace(22.4, 22.85, 8)) # wind = [2]*8 angle = [90]*8 # 为方便比较长度,箭头方向设置成一样 lon = [114.27] * 8 # 为方便比较长度,箭头经度设置成一样 # 指定地图范围、投影方式(projection)等 area_thresh是与湖泊等在地图上显示相关的参数 m = Basemap(llcrnrlon=113.7, llcrnrlat=22.35, urcrnrlon=114.7, urcrnrlat=22.9,\ rsphere=(6378137.00,6356752.3142),\ resolution='l', area_thresh=1000., projection='lcc', lat_1=22.5, lat_0=22.5, lon_0=114,ax=ax) # 一系列的U、V ver = [-spd*math.sin(math.radians(agl)) for spd,agl in zip(wind, angle)] # U分量 hriz = [-spd*math.cos(math.radians(agl)) for spd,agl in zip(wind, angle)] # V分量 print(ver, '\n', hriz) ax=plt.gca() #下面两行是读取地图中的shape文件,即轮廓图 # m.readshapefile(r'G:\深圳季风研究\gadm36_HKG_shp\gadm36_HKG_0', 'states',color='grey') #HongKong # # m.readshapefile(r'G:\深圳季风研究\gadm36_CHN_shp\gadm36_CHN_3', 'states',color='grey') #Mainland in given lon and lat # m.readshapefile(r'G:\深圳季风研究\gadm36_sz_shp\Bon_data\xzq_sz_pop', 'states', color='grey') m.scatter(lon, lat, s=2, color='goldenrod', marker="o", latlon=True) #根据经纬度,画出对应站点位置 ax.set_title('风场') # ax.quiver(lon, lat, ver, hriz, units='width', scale=2, width=0.01, color='deepskyblue') m.quiver(lon, lat, ver, hriz, color='deepskyblue', width=0.005, scale=30, latlon=True) for i, wspd in enumerate(wind): ax.annotate(str(wspd), (lon[i], lat[i])) # 在图上添加一些文字信息 plt.text(0.6,0.9, r'$mean: $'+str(18) + '°', color='forestgreen',transform=ax.transAxes, fontweight='extra bold') plt.text(1.02,0.6, r'$S: $' + str(18) + '%', color='forestgreen',transform=ax.transAxes, fontweight='heavy') plt.text(1.02,0.4, r'$N: $', color='forestgreen',transform=ax.transAxes, fontweight=100) # 画经纬度网格 m.drawmeridians([114.0,114.4], labels=[1,0,0,1]) # meridian:子午线,经线 arange指明范围和间隔 m.drawparallels(np.arange(15, 30, 0.3), labels=[1,0,0,0]) # 画纬度平行线 # 比例尺长度的U、V值和位置 spd = 2 angle_all = 90 ver_all = -spd*math.sin(math.radians(angle_all)) hriz_all = -spd*math.cos(math.radians(angle_all)) # ax.quiver(q_lon, q_lat, ver_all, hriz_all, color='g', pivot='mid') # mid是旋转枢纽在中间,默认在尾部 m.quiver(114.27, 22.75, ver_all, hriz_all, color='g', scale=30, latlon=True) # 画比例尺 plt.text(0.82,0.1, r'$scale:$', color='r',transform=ax.transAxes, fontweight=100, fontsize=8) plt.text(0.82,0.03, r'$2m/s$', color='r',transform=ax.transAxes, fontweight=100, fontsize=8) m.quiver(114.62, 22.375, 3, hriz_all, color='r', width=0.005, scale=50, latlon=True) print(-ver_all, hriz_all) # 这一段与画箭头不相干,可忽略注释掉 画散点,为不同散点设置不同颜色 # Colors=('#DDDDFF','#7D7DFF','#0000C6','#000079','#CEFFCE','#28FF28','#007500','#FFFF93') # sc = plt.scatter(lon, lat, s=100, color=Colors, marker="o") #根据经纬度,画出对应站点位置 # for i,txt in enumerate(Colors): # ax.annotate(txt,(lon[i],lat[i]), fontsize=5) plt.show()
-
Quiver-3.2.7.dmg
2020-08-06 23:08:06macOS系统笔记软件:Quiver-3.2.7,支持多种代码高亮,适合记录内嵌代码的笔记,程序员笔记软件。 -
matplotlib quiver箭图绘制案例
2020-09-17 13:08:29主要介绍了matplotlib quiver箭图绘制案例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧 -
matlab开发-Quiver5
2019-08-24 14:14:43matlab开发-Quiver5。使用真正的三维箭头绘制箭头 -
Quiver快速入门
2018-07-18 15:43:00Quiver快速入门 装载自:https://github.com/HappenApps/Quiver/wiki/Quiver%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8 Quiver 是一个程序员专用的记事本应用,可轻松混合文本、代码、Markdown、LaTeX 到...Quiver快速入门
装载自:https://github.com/HappenApps/Quiver/wiki/Quiver%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8转载于:https://www.cnblogs.com/niuli1987/p/9329497.html
-
Attaching bow to arrow quiver
2020-12-09 01:08:32<div><p>Along with the backpack, we also have the arrow quiver. It would make sense to attach the bow to the quiver to free our hands otherwise it's always better to have a backpack than an arrow ... -
quiver函数简介
2012-09-23 15:57:07主要介绍了quiver函数的一些用法,很好的学习资料,大家可以借鉴一下。 -
matlab开发-quiver3Dpatch
2019-08-24 03:15:18matlab开发-quiver3Dpatch。基于补丁命令的彩色三维箭头绘制 -
[Suggestion] Quiver
2020-12-04 13:51:43d like to suggest a Quiver be added to TC. Perhaps it could be implemented by allowing TiCo arrows and bolts to be added directly to the TiCo "vest" slot, or a single-slot container that goes ... -
matlab quiver
2012-03-09 20:41:00quiver(x,y,u,v)绘制的是从点(x,y)处指向(u,v)处的矢量 quiver(x,y,u,v,scale),scale的默认值可能是0.9 转载于:https://www.cnblogs.com/newlangwen/archive/2012/03/09/2388279.html... -
Quiver holds different types of arrows
2021-01-12 03:26:49<div><p>Now a quiver can hold different types of arrows. <p>If a quiver holds different types of arrows, it is represented : ... -
Quiver可视化Keras的交互式convnet特性
2019-08-10 05:18:59Quiver:可视化Keras的交互式 convnet特性 -
quiver()函数
2019-07-16 10:30:001.quiver函数 一般用于绘制二维矢量场图,函数调用方法如下: 1 quiver(x,y,u,v) 该函数展示了点(x,y)对应的的矢量(u,v)。其中,x的长度要求等于u、v的列数,y的长度... -
Survivor harness, quiver and arrows weirdness
2021-01-12 02:34:39However, if I equip a quiver with arrows and start picking up more arrows, once the quiver fills up, arrows do go into the harness. I can then drop the quiver and arrows will stay in the harness. ... -
matplotlib quiver箭图绘制
2018-06-16 11:50:21quiver绘制表示梯度变化非常有用,下面是学习过程中给出的两个例子,可以很好理解quiver的用法 from pylab import * close() ## example 1 x = linspace(0,10,40) y = x**2*exp(-x) u = array([x[i+1]-x[i] for... -
Quiver:Minecraft的资源包创建者和经理-源码
2021-02-04 08:12:44首先,您需要下载Quiver的一个版本(最好是最新版本) (应该是zip) ,然后您需要解压缩它,然后运行Quiver.bat或Quiver (取决于您使用的是Windows还是Linux) /苹果系统) 该程序需要Java 8 JRE。 它不兼容更高... -
Quiver(MAC记事本)特别版2.0中文安装版
2019-07-25 08:34:10《Quiver》mac版是在Mac os平台上的一款Mac记事本软件!《Quiver》主要功能就是帮助用户记录重要文字,这款软件界面简介,炒作简单,可以帮助用户轻松的记录混合文本、代码、Markdown 文本到一个记事本中,使用非常... -
quiver绘制python语言
2020-04-01 14:53:21''' =======================================================...Demonstration of advanced quiver and quiverkey functions ======================================================== Known problem: the plot... -
MATLAB中三维向量的绘制以及坐标点的推算(quiver3,quiver,plot3,plot)
2020-12-23 13:10:52多维数组值传递、quiver3、quiver、plot3、plot等用法以及向量归一化问题实例解析! -
quiver-log:Dart的日志记录实用程序-源码
2021-02-17 08:36:47Quiver日志是一组日志记录实用程序,可轻松配置和管理Dart的内置日志记录功能。 文献资料 可用。 基础 Dart的内置日志记录实用程序级别较低。 这意味着每次启动新项目时,都必须复制/粘贴一堆日志记录配置代码以设置... -
FALCON vs HGAP > Celera > Quiver
2020-12-09 03:53:48Quiver. Is there an application where one would be better than another and if I run FALCON do I still need to follow it up with Celera and Quiver? Thanks for any insights you can provide.</p><p>该...