对箭袋图中的速度信息进行下采样
我有两个数组 (vel_y,vel_z) 分别表示 y 和 z 方向的速度,它们的形状都为 (512,512),我试图使用颤动图来表示。 以下是我绘制箭袋的方式:
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0,512,num=512)
[X,Y] = np.meshgrid(x,x)
fig, ax = plt.subplots(figsize=(7,7))
ax.quiver(X,Y,vel_y,vel_z,np.arctan2(vel_z,vel_y),pivot='mid',units='x',scale=2)
arctan2() 调用使不同的方向具有不同的颜色,如 这个答案。 显然,绘制所有 5122 这些箭头会导致绘图变得混乱且难以解析,您可以在此处看到: 箭袋图。
我想知道是否有更好的方法来缩放/表示箭头,使其更具可读性?
但是,我遇到的主要问题是如何“缩减采样”此速度信息,例如从绘制 5122 箭头到 1002 。这是否需要在定义速度的点之间进行插值?
谢谢你!
I have two arrays (vel_y,vel_z) representing velocities in the y and z directions, respectively, that are both shaped as (512,512) that I am attempting to represent using a quiver plot.
Here is how I plotted the quiver:
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0,512,num=512)
[X,Y] = np.meshgrid(x,x)
fig, ax = plt.subplots(figsize=(7,7))
ax.quiver(X,Y,vel_y,vel_z,np.arctan2(vel_z,vel_y),pivot='mid',units='x',scale=2)
The arctan2() call is so that different orientations are colored differently as in this answer.
Obviously plotting all 5122 of these arrows makes for a jumbled and difficult to parse plot, which you can see here:
Quiver Plot.
I was wondering if there was a better way to scale/represent the arrows so that it is more readable?
However, the main question I have is how I could 'downsample' this velocity information to go from plotting 5122 arrows to 1002 for example. Would this require interpolation between points where the velocity is defined?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实现此目的的简单方法是在给予颤抖的每个向量中取 N 中的一个点。
对于给定的
np.array
,您可以使用以下语法来执行此操作:a[::N]
。如果您有多个维度,请在每个维度中重复此操作(您可以为每个维度提供不同的滑动):a[::N1, ::N2]
。在您的情况下:
您不需要插值,除非您想在测量/模拟/其他内容的网格中未定义的点处绘制速度。
The simple way to do this is simply to take one point over N in each vectors given to quiver.
For a given
np.array
, you can do this using the following syntax:a[::N]
. If you have multiple dimensions, repeat this in each dimension (you can give different slip for each dimension):a[::N1, ::N2]
.In your case:
You don't need interpolation, unless you want to plot velocities at points not defined in the grid where you have your measurements/simulations/whatever.