Matlab how to fill boom heads

I make 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 arrowheads to be full (i.e. enter image description here , but not enter image description here )

From the documentation, this should be pretty simple using

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

However, I still could not understand the correct syntax - they do not work:

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

Thank you for your help!


edit: Using string qualifiers does the following:

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

enter image description here

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

enter image description here

+7
matlab plot
source share
2 answers

I am not a MATLAB professional, so please excuse me if my answer is awkward. I am sure there are more elegant ways to solve this problem - this is what I found.

I decided to solve this problem by finding the positions of the arrows, deleting them and repainting them with fill (as Day suggested). I noticed that I can tell fill that one polygon ends, and the next starts by inserting NaN values ​​(this is also a way to draw the original arrow tips, as you can see the original XData ). Having done this, I lost the ability to influence the color of objects, and they did not fill up. In the process, I drew new arrowheads in a loop - I know that there may be a better way to do this, so I'm glad of any addition.

I used the example you provided, replacing only the last line with HANDLE = quiver(x,y,u,v); to get the plot descriptor. From there:

 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 arrow descriptors in the ArrowTips variable. Feel free to specify Edge- and Facecolor in the call to fill , here are black and red, respectively.

+3
source share

This code, in response to a similar question, works pretty well, actually. It uses annotations.

In Matlab, how do I change the style of the arrowhead in the area of ​​the quiver?

0
source share

All Articles