没有箭头茎的箭袋图 [英] Quiver plot without arrow stem
问题描述
我正在 MATLAB 中模拟粒子的运动.我正在使用 quiver
来获得它们的运动方向.但是,我只想有没有茎的箭头.我无法做到这一点.
I am simulating the motion of particles in MATLAB. I am using quiver
to be able to get the direction of their motion. However, I would like to have only the arrowhead without the stem. I am unable to achieve this.
我尝试使用以下方法,
quiver(x,y,vx,vy,'LineStyle','none','ShowArrowHead','on')
去掉茎,但箭头也没有出现.有没有办法解决这个问题?
to get rid of the stem, but the arrowhead too does not show up. Is there a way around this?
推荐答案
'LineStyle','none'
不起作用,因为样式同时适用于词干和头部,因此设置它到 none
隐藏两者.
'LineStyle','none'
didn't work because the style applies both to the stem and to the head, so setting it to none
hides both.
这可以通过挖掘 Quiver
对象的一些未记录的属性来解决.探索 Quiver
对象的属性(使用 struct(
)我们可以看到一个箭袋图有 NodeChildren
属性,并且它由 4 个元素组成,
This can be solved by digging around some undocumented properties of the Quiver
object. Exploring the properties of a Quiver
object (using struct(<handle to quiver plot>)
) we can see that a quiver plot has NodeChildren
property, and that it is made of 4 elements,
>> hq = quiver(x,y,u,v);
>> hq.NodeChildren
ans =
4×1 graphics array:
ListOfPointsHighlight
LineStrip
LineStrip
Marker
您在上面看到的 LineStrip
对象从上到下对应于尾部和头部.从这里开始,只需通过它们的 Visible
属性隐藏尾部:
The LineStrip
objects you see above, correspond, from top to bottom, to tails and the heads. From here it's just a matter of hiding the tails via their Visible
property:
[x,y] = meshgrid(0:0.2:2,0:0.2:2);
u = cos(x).*y;
v = sin(x).*y;
figure();
hq = quiver(x,y,u,v);
pause(0.1); % this appears to help
hq.NodeChildren(2).Visible = 'off';
结果:
在 R2019a 上测试.
Tested on R2019a.
这篇关于没有箭头茎的箭袋图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!