4.57143

4.6 | 58 ratings Rate this file 540 downloads (last 30 days) File Size: 17.31 KB File ID: #278

arrow.m

by Erik Johnson

 

14 Jan 2000 (Updated 20 May 2009)

Code covered by the BSD License  

Draw a line with an arrowhead.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

Download Now | Watch this File

File Information
Description

ARROW (5/20/2009) Draw a line with an arrowhead.

ARROW(Start,Stop) draws a line with an arrow from Start to Stop (points should be vectors of length 2 or 3, or matrices with 2 or 3 columns), and returns the graphics handle of the arrow(s). By itself, ARROW will use the mouse to allow selection.

ARROW DEMO & ARROW DEMO2 show 3-D & 2-D demos of the capabilities of ARROW.

ARROW PROPERTIES shows the properties that can be set (length, base angle, tip angle, width, which ends have arrowheads, etc.)

Acknowledgements
This submission has inspired the following:
Random Boolean Network Toolbox, arrowflow, quiver2.m v1.2 (Nov 2009)
MATLAB release MATLAB 6.5 (R13)
Zip File Content  
Other Files arrow.m,
license.txt
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (61)
17 Dec 2002 a c

greatest function ever!

02 Feb 2003 Aslak Grinsted  
17 Feb 2003 Niclas Borlin

Great!

01 May 2003 M Bakht

It is just great. Amazing.

03 Jul 2003 Jakob van de Laar

Great package, it should be incorporated in
the standard Matlab distribution

12 Oct 2003 Benedikt Halldorsson

Neat package, but (unless I'm missing something obvious) renders itself essentially USELESS.
Try setting the linestyle of the arrow line to dotted (set(h,'linestyle',':') and then try printing it out to a file (print -depsc test.eps) and view the postscript image. The line certainly is not dotted (on Matlab 6.5). Same problem with dashed and dot-dashed lines.
I'm not sure if this is an arrow.m problem, or Matlab's.

05 Jan 2004 Bernhard Boeck

That's exactly what I'm looking for

24 Feb 2004 Arnd-Ragnar Rhiemeier

Excellent package. Help topics very comprehensive. Easy to use. Quickly leads to appealing graphical output. This package is exactly what I was looking for.

06 May 2004 ke wang

Very Useful and convenient. Easy to use!!

09 Jun 2004 Gerald Dalley

Very nice

26 Jul 2004 Kelvin Rocha

Very useful. Explanations are excellent. Exactly what I was looking for.

06 Oct 2004 Mattias Forsblom

Excellent.

06 Oct 2004 Eddie Fiorelli

Excellent work, thorough documentation. Thanks!

14 Oct 2004 Olivier Marsden

Very useful!

13 Dec 2004 Nathaniel de Lautour

Superb effort. Highly configurable, easy to use and well documented to boot.

16 Jan 2005 Rattikan Saelim  
20 Feb 2005 Evan Westwood

Couldn't figure out how to make the arrow line and arrow head have a specific color. Arrowheads didn't look as nice as those you might plot in drawing/presentation packages such as Powerpoint.

02 May 2005 Ian Mackenzie  
25 May 2005 Janik Zikovsky

Very good, better than annotation('arrow') because it is in axis units!

29 Jul 2005 Dave Cogdell

This code (specifincally including the documentation (which is at the same time incomplete and inadequate) is far too complex for the simple thing(s) it does. I believe the author is an engineer: he should refrain from trying to write like a computer scientist and write like an engineer.

29 Aug 2005 Changshun Deng

Good script!

13 Sep 2005 Amit Kesar

Very good. Thank you.

18 Sep 2005 Sharoni Shafir

Works great, thanks!

25 Sep 2005 Vijaykumar Sathyamurthi

Thanks for this excellent tool. I hope you continue writing such winderful codes!!!

22 Oct 2005 Shane Lin

I add the following comment at the file head. arrow(Start,Stop,'EdgeColor','b','FaceColor','b') color arrow.

15 Dec 2005 super tanne  
06 Feb 2006 Very satisfied

Exactly what I needed. Perfect!

14 Feb 2006 Jasper Menger

Nicely done. A shame by the way Matlab doesn't seem to have a builtin function for drawing arrows from the command line.

14 Mar 2006 JR P

This is great. I hate how MATLAB uses normalized figure coordinates in their annotation() call for drawing arrows. It makes no sense and someone at MathWorks got lazy, so it becomes nearly useless. This code is exactly what they should have done.. good job Erik!

24 Aug 2006 heath kitson

thanks eric

09 Sep 2006 Nithya C.R.

The program is really great with all the aspects of plotting a directed line excellently covered.

04 Oct 2006 J Xu

this program is really good, easy-use. 3x Erik.

30 Oct 2006 Arun Karthi Subramaniyan

Great tool. Very easy to use with detailed documentation. Thanks for sharing it with us.

29 Dec 2006 Vassili Pastushenko

Good job. A small remark:

arrow([0 0],[1 1],50,10,30)

does not point to (0,1).

Probably it would be reasonable to add a feature of automatical swapping baseAngle and tipAngle, if baseAngle < tipAngle.
 

29 Dec 2006 Vassili Pastushenko

does not point to (1,1)

18 Apr 2007 Ramesh Rajasekaran  
22 Apr 2007 jonny e

Excellent and easy to use. I'd emphasize that one should call axis(axis) prior to plotting the arrow, or the axis limits will get reset which will render the arrow incorrectly. This is noted in the help, but tucked towards the bottom.

31 May 2007 B Gurt

Does exactly what it needs to do.

08 Aug 2007 Jorge Marin  
04 Oct 2007 Dustin Kruse

works perfectly

09 Oct 2007 Rutty Bee

Ruins the figure when plotting 3-D arrows with z-components. In this case, the width of the arrowhead becomes so large that the plot is rendered unusable. This is the case no matter how one tries to set its size.

24 Oct 2007 Ahmet Sacan

Does not work when called in a deployed application (i.e., when called from the executable generated using mcc).

31 Oct 2007 Tuan Hoang

sorry, how to add this graphic handle (return value) to an existing axes, figure.

04 Feb 2008 Matthijs Klomp

Works great.

27 Apr 2008 Alex Fard  
22 May 2008 Xuzhang Shen

good

10 Jun 2008 GDR! x

One can change the colour of an arrow by specifying 'FaceColor' and 'EdgeColor' properties, which is, unfortunately, not documented.

25 Jun 2008 Dmitry Vasilyev

OMG! Just exactly what I was looking for! Excellent job, thank you Eric!

02 Jul 2008 Joselito Dimayuga

the purpose of this Dir or format is for ?????

15 Jul 2008 lili kalmer  
16 Aug 2008 Leonardo Duarte  
29 Aug 2008 Saeed Taherion  
30 Jan 2009 Ke

very useful.

10 Feb 2009 Hiram

to set the color of the arrow, see this example:
axis([0 3 0 3 0 3]);
grid on
h=arrow([3 3 3],[0 0 0],36,'BaseAngle',60);
set(h, 'FaceColor', 'b');
set(h, 'EdgeColor', 'r');
Awesome application!

16 Jun 2009 Jianbo

Excellent. One little problem is that the arrow created is a little different from the one inserted manually through the "insert" menu. For example, the position can not be adjust by mouse.

20 Jul 2009 Gabriel Akira Schreiber

The arrowheads look distorted. Even the arrowheads in the demo look distorted.

07 Oct 2009 never change

amazing,very useful

10 Nov 2009 Lorenzo Guerrasio

It looks really great...I'll start use instead of quiver!

15 Dec 2009 Aamir  
27 Dec 2009 Aamir  
17 Jan 2010 Rob Campbell

Useful in many ways but the code is very complicated and it's not clear how to attain specific effects without trawling through the function body. Why not put demo code in a separate file?

Please login to add a comment or rating.
Updates
20 May 2009

Replace "eval('trycmd','catchcmd')" with "try, trycmd; catch, catchcmd; end;", which break's compatibility with MATLAB 5 but improves compliance with newer versions.

20 May 2009

actually update the file (not just the description); correct view on demo

Tag Activity for this File
Tag Applied By Date/Time
annotation Erik Johnson 22 Oct 2008 06:35:15
customization Erik Johnson 22 Oct 2008 06:35:15
arrow Erik Johnson 22 Oct 2008 06:35:15
arrowhead Erik Johnson 22 Oct 2008 06:35:15
graphics Erik Johnson 22 Oct 2008 06:35:15
line Erik Johnson 22 Oct 2008 06:35:15
potw Shari Freedman 29 May 2009 09:23:55
arrow Yang Bai 28 Oct 2009 06:19:07
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com