File Exchange

image thumbnail

ARROWS: generalized 2-D arrows plot

version 1.1 (3.6 KB) by

Vectorized and flexible arrow plot function in 2-D



View License

This little function is an alternative to other existing arrow plot functions, since it has very simple, vectorized and effective coding. In fact, arrows are all plotted with a single patch command! The function also accepts any standard patch parameter/value pair like 'FaceColor', 'EdgeColor', 'LineWidth', etc.

It can be used to plot a personalized arrow at coordinates X,Y with length L and azimuth AZ, or any of these arguments can be vector or matrix, like QUIVER did, to plot multiple arrows. The option 'Cartesian' allows defining U and V components instead of polar L and AZ.

Arrow's aspect ratio, head and segment line shapes are configurable with 4 parameters: head width, head length, head inside length and segment line width, all normalized to arrow's length. See the upper part of examples figure.

It is also possible to vary only the arrow length with fixed head and line width, using a reference length. The examples figure shows the effect of this option: upper arrows use a reference length, while lower arrows do not.

Comments and Ratings (3)

Works good!!

Here is my extension for parent axes and the new app ui axes workaround (use line instead of patch):

add at line 26:
% Additionally 'Parent' specifies the axes to draw (default is current axes).

add at line 104:
[s,ax,varargin] = checkparam(varargin,'parent','ishandle');
if ~s
ax = gca;

replace line 154 with:
if isa(ax, 'matlab.ui.control.UIAxes')
    hh = line(ax, -fx.*l.*cos(az) + fy.*l.*sin(az) + x,fx.*l.*sin(az) + fy.*l.*cos(az) + y,'Color','k',varargin{:});
    hh = patch(ax, -fx.*l.*cos(az) + fy.*l.*sin(az) + x,fx.*l.*sin(az) + fy.*l.*cos(az) + y,'k',varargin{:});


irfan (view profile)



New options:
- 'Cartesian': define (U,V) instead of (L,AZ)
- 'Ref', REFLENGTH : fixes head and width relative to a reference length

MATLAB Release
MATLAB 6.5 (R13)
Tags Add Tags

Inspired: draw

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video