Matlab how to fill quiver arrow heads

I am making a quiver plot :

[x,y] = meshgrid(0:0.2:2,0:0.2:2);
u = cos(x).*y;
v = sin(x).*y;
figure
quiver(x,y,u,v)

I want the arrow heads to be filled (ie and not )

From the documentation, it should be pretty straightforward by using

quiver(...,LineSpec,'filled')

However, I still couldn't figure out the right syntax - these do not work :

quiver(x,y,u,v,'LineWidth','filled');
quiver(x,y,u,v,'LineWidth',1,'filled');

Thanks for your help!


edit : Using line specifiers does the following:

quiver(x,y,u,v) %Original

在这里输入图像描述

quiver(x,y,u,v,'-sk','filled') %With line specifiers

在这里输入图像描述


I am not a MATLAB professional, so please excuse if my answer is clunky. I am sure there are more elegant ways to solve this - the following is the one I found.

I decided to solve this retrieving the positions of the arrow tips, deleting them and repaint them with fill (like Deve suggested). I noticed that I can tell fill that one polygon ends and the next begins through inserting NaN values (thats also the way the original arrow tips are drawn, as you can see inspecting the original XData ). Doing so I lost the possibility to influence the color of the objects and they didn´t get filled. As a work-around I painted the new arrow-tips in a loop - I know there might be a better way to do it, so I am happy about any addition.

I used the example you gave, only replacing the last line by HANDLE = quiver(x,y,u,v); to get the handle to the plot. From there on:

children=get(handle,'children'); % retrieve the plot-children - 
                                 % second element are the arrow tips

XData=get(children(2),'XData'); % retrieve the coordinates of the tips
YData=get(children(2),'YData');

hold on
delete(children(2))  % delete old arrow tips

for l=1:4:length(XData)-3   % paint new arrow tips, skipping the NaN-values
    ArrowTips((l-1)/4+1)=fill(XData(l:l+2),YData(l:l+2),'r');
end

You can then find the handles to the arrow-tips in the ArrowTips-variable. Feel free to specify the Edge- and Facecolor in the call to fill , here being black and red respectively.


This code in an answer to a similar question works quite well, actually. It uses annotations.

In Matlab how do I change the arrow head style in quiver plot?

链接地址: http://www.djcxy.com/p/19870.html

上一篇: 错误解析build.sbt中的表达式

下一篇: Matlab如何填充箭头箭头