View License

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

» Watch video

Highlights from
Arrow3 Version 5

4.7 | 26 ratings Rate this file 102 Downloads (last 30 days) File Size: 430 KB File ID: #14056 Version: 1.15
image thumbnail

Arrow3 Version 5


Tom Davis (view profile)


22 Feb 2007 (Updated )

Draws lines with directional arrowheads.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

ARROW3(P1,P2) draws lines from P1 to P2 with directional arrowheads. P1 and P2 are either nx2 or nx3 matrices. Each row of P1 is an initial point, and each row of P2 is a terminal point.

ARROW3(P1,P2,S,W,H,IP,ALPHA,BETA) can be used to specify properties of the line, initial point marker, and arrowhead. Type "help arrow3" at the command prompt for more information

What's new in Version 5:

All arrowhead and initial point marker sizes (W, H, and IP) are relative to the PlotBox diagonal.

Version 5 attempts to preserve the appearance of existing axes. In particular, ARROW3 will not change XYZLim, View, or CameraViewAngle. ARROW3 does not, however, support stretch-to-fill scaling. If a particular aspect ratio or variable limit is required, use DASPECT, PBASPECT, AXIS, or XYZLIM commands before calling ARROW3. Users are encouraged to report problems directly to the author.


Arrow3 Version 4.58 inspired this file.

This file inspired Particle Point Analysis, M Arrow3.M Easy To Use 3 D Arrow, and Determination Of The Minimum Distance Between Two Super Ellipsoids Surfaces. Using Optimization.

MATLAB release MATLAB 6.5 (R13)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (44)
07 Feb 2017 Subhash Pidaparthi

Thank you Tom

24 Sep 2016 Tom Davis

Tom Davis (view profile)

Hello, Ikem --

Extract the files to a folder, e.g. C:\arrow3.

Then in the MATLAB Command Window:

cd C:\arrow3
help arrow3

Comment only
23 Sep 2016 Ikem Solomon

Please how do I install it. I am having problems attaching it to my matlab

Comment only
14 May 2016 Tom Davis

Tom Davis (view profile)

Hello, John --

This works for me:

load durer
axis image
hold on
arrow3([235 215],[130 465],'r-2.5',1.5)
hold off

Comment only
13 May 2016 John Peter Davalos

Arrow head not showing if plotted over an image?

Comment only
04 May 2016 Gopal Karemore

Thank you Tom!

19 Nov 2015 Liya Wang

Hello Tom,

Sorry I make a mistake.I mixes up lon and lat.I can draw arrows on worldmap now.You can ignore my question earlier.Thank u very much!

Best wishes.


Comment only
19 Nov 2015 Liya Wang

Hello Tom,
Thank you for your answer.When I draw 2D arrows,which plotting functions in your code make it work? I just find plot3.Could you please tell me all plotting functions you used in your code .

Comment only
18 Nov 2015 Tom Davis

Tom Davis (view profile)

Hello, Liya --

I have neither the Mapping Toolbox nor a recent version of MATLAB. If you can ask specific questions, I may be able to help.

Good luck and best wishes.

-- Tom

Comment only
18 Nov 2015 Liya Wang

hello Tom,I want to ask you a question.When I use the function worldmap and draw arrows on it,I try to modify your code,but I can't.Could you please modify your code so that it can be used on the worldmap.Thank u so much!

02 Jul 2015 Le

Le (view profile)

Thanks a lot! The function is very useful

26 Jun 2015 Adam Danz

Adam Danz (view profile)

Nice, saved me from a lot of footwork.

12 Dec 2014 tao song

I love this .m file.

03 Apr 2014 Andreas J.

sorry i didn't want to submit the last voting. I didn't read the "relative to the PlotBox diagonal" at the time i was about to write a critic, but as i reread the description i closed the tab.

But i still think that this is an annoying feature, i would like it more if i could choose wether it should be relative or a fix size. I also don't like that it clears the axes. I know a workaround but it's still annoying me everytime i have to use arrow3. Just my opinion.

02 Apr 2014 Andreas J.

11 Mar 2014 Daniel Frisch

01 Jun 2013 yang yang

Thanks for your arrow3 program.

17 Jan 2013 Ben

Ben (view profile)

Great code. Have been using it for quite a long time.

Comment only
17 Jan 2013 Ben

Ben (view profile)

16 Jan 2013 Matthew

15 Jan 2013 Tom Davis

Tom Davis (view profile)

Hi, Jonas --

Please try version 5.15. Thanks.

-- Tom

Comment only
07 Jan 2013 Jonas

Jonas (view profile)

I've downloaded arrow3 sometime in 2002 for the first time; great job, guys!

In order to avoid possible conflicts with other code writing to the 'UserData' property, I suggest replacing these calls by "setappdata(ax,'arrow3',value)"

12 Aug 2012 Ji?í

Ji?í (view profile)

It does not ignore zero magnitue input (R2012a).

>> arrow3([1 1],[1 1])
Error using arrow3 (line 373)
P1 cannot equal P2

Comment only
23 Mar 2012 Jeonghyun Seo

13 Mar 2012 Xilu Wang


11 Dec 2011 Daniel

Daniel (view profile)

Hi Tom,

thanks for that nice contribution. I would enjoy if you could modify the input arguments with string propertys (similar to most of the inbuilt-functions (f.e. 'LineWidth', 2)), in particular to add a 'Parent' property to get rid of the problems with multiple axes!


Comment only
26 Jul 2011 Tom Davis

Tom Davis (view profile)

Hello, Tomazc --

Please try this and write if you have questions. Thanks.

% Animation Example
t=(0:pi/40:8*pi)'; u=cos(t); v=sin(t);
grid on, view(35,25)
hold on
p=[20*t,u,v]; inc=4:1:length(t);
p2=p(inc,:); p1=p(inc-1,:);
for i=2:1:length(p1)
hold off

Comment only
23 Jul 2011 solo

solo (view profile)

19 Jul 2011 Tomazc

Tomazc (view profile)

I'd like to use arrow3 in animation (for function) where only one arrow will be shown, so i cannot use 'hold on'.
In this case the 'axis' are not working, but i need the same view.

Any suggestion?

axis([-400 400 -400 400 -100 700])
whitebg([1 1 1]);
view(35, 25)
grid on

for i = 1:1:15

Comment only
07 Feb 2011 Sauro Salomoni

Does what it's supposed to do, and the help files are VERY detailed. Thank you very much! :)

05 Aug 2009 Gabriel Akira Schreiber

20 Jul 2009 Gabriel Akira Schreiber

02 Apr 2009 Tom Davis

Tom Davis (view profile)

Instead of using Copy Figure from the Edit menu, use Save As from the File menu, save the figure as a PNG file, and then insert the PNG file into Word.

Comment only
01 Apr 2009 Lei Shang

Very useful with 3D plots. But when I'm copying figures to word, all the nice arrows plotted by 'arrow3.m' disappeared. And my command window displays:

Warning: RGB CData not yet supported in Painter's mode
> In graphics\private\restorehg at 100
In graphics\private\restore at 29
In print at 277
In editmenufcn at 78

How do I fix this?

Comment only
01 Apr 2009 Lei Shang

23 Jan 2009 Tom Davis

Tom Davis (view profile)

Wide lines may obscure the arrowhead tip, but the line endpoint and arrowhead tip are _always_ coincident.

Comment only
21 Jan 2009 Philipp Wissgott

On my matlab (R2007a) the line of the arrow is visible after the tip of the arrowhead in 2D plots. It looks like as if the arrowhead is plotted at the wrong position.
In my example arrow3 is called after some calls of "line()" and "rectangle()". I can supply further information if required.

29 Dec 2008 Tom Davis

Tom Davis (view profile)

It is not necessary to set AXIS EQUAL, but commands that may change the aspect ratio should be issued _before_ calling ARROW3. ARROW3 draws surfaces that look like right circular cones and spheres no matter the aspect ratio, but the ratio must be fixed, and changing the ratio will distort the surfaces.

There are many examples in the HTML files that illustrate how to use ARROW3 before and after PLOT, POLAR, CONTOUR, PLOT3, SURF, SLICE, and PATCH.

Comment only
27 Dec 2008 piao lin

it seems if I want to plot another plot3(......) with arrow3(.....)

I should

hold on;
axis equal ; %you'd better use axis equal

if I put plot3(....) before arrow3(.....) ,just like below ,I get not see the result of arrow3(.....);

hold on;
axis equal ; %you'd better use axis equal

13 Dec 2008 Vaibhav Deshpande

I am doing a project in layup optimization of balanced symmetric laminates, and I wanted to display at each call to fmincon the material direction for my laminate, I was able to so by using arrow3, thank you.

Vaibhav Deshpande.

Comment only
12 Sep 2008 Georg Stillfried

works fine

13 Apr 2008 dong ding

it's excellent.I can use it to draw my picture. thanks!

24 Oct 2007 Ahmet Sacan

I was happily using arrow.m until I came to see that it for some reason did not draw anything when my m file was deployed (i.e., running executable that resulted from mcc). I came back to File Exchange for a different arrower instead of trying to debug arrow.m. Now I'm using arrow3 which works fine in deployed mode. thanks.

13 Mar 2007 maricel miguel

I havent tried it but looks good from the screen shot, what was the thought process on this one, and how long did it took you

12 Mar 2007

improved code metrics

11 Apr 2007

added dialog

11 Apr 2007

added dialog

13 Apr 2007

dialog revision

29 May 2007

magnitude coloring and documentation revision

04 Jun 2007

more examples

05 Jun 2007

more examples

15 Jun 2007

corrected example 2

18 Jun 2007

simplified example 10

25 Jun 2007

added example references; check for empty input

25 Jun 2007

added example references; check for empty input

02 Jul 2007

modified named colors to match default ColorOrder

09 Jul 2007

modified named colors to match Simulink colors

16 Jul 2007

revised html files

17 Jul 2007

new screenshot

25 Jul 2007

ignore zero-magnitude input

10 Sep 2007

added cone plot option

01 Oct 2007

changed screenshot

24 Oct 2007

zero magnitude bug fix

17 Mar 2008

updated contact information

13 May 2009 1.2

corrected spelling errors

27 Jul 2011 1.3

updated html files and added animation example

27 Jul 2011 1.8

updated html files and added animation example

01 Aug 2011 1.9

improved html appearance in File Exchange viewer

03 Aug 2011 1.10

corrected DOCTYPE

15 Jan 2013 1.14

use appdata instead of userdata

15 Jan 2013 1.15

use appdata instead of userdata

Contact us