View License

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

» Watch video

Highlights from
Draw lines with arrows

1.0 | 1 rating Rate this file 5 Downloads (last 30 days) File Size: 2.46 KB File ID: #38278 Version: 1.1
image thumbnail

Draw lines with arrows


Sabesan (view profile)


21 Sep 2012 (Updated )

Draw lines with arrows. Multiple optional parameters are given for controlling the arrow and line

| Watch this File

File Information

draw_line2 draw directional vector points in 2D with directional arrows

draw_line2(p1, p2) draw line with defulat optional parameters;
draw_line2(p1, p2 , param1, val1, ...)
The line with stretching(<-->) and compressive(>---<) arrows or without
 arrows (----) can be plotted.

Input arguments:
 p1, p2 : Cordinates of the two points in 2D

Optional parameters ( passed as parameter/value pairs):

'LineColor' : Colour of line ( vector of colour or char)
                    default : % 'b'
'LineWidth' : Width of the line (Scaler values)
                    default : 5)
'ArrowDirection' : (0,1,2) (0 : p1--- p2, 1: p1 --> p2 2: and P1 <-> p2)
                    default : 1
 'ArrowLength' : Length of the arrow ( scaler values)
                    default : 3
'ArrowIntend' : Intended arrow ( scaler value)
                    default : 1
'ArrowAngle' : Angle of arrow with the main line in degree
                    default : 30
'ArrowColor' : Arrow face clour ( in color vector or char)
                    default : 'r'
'ArrowEdgeColor : arrow edge colour ( in colour vector or char or
                    default : 'k'

   draw_line2([0 0]', [100 100]',...
                    'Linecolor', 'b',...
                    'LineWidth', 5 ,...
                    'ArrowDirection, 2,...
                    'ArrowLength, 10,....
                    'ArrowIntend, 3,...
                    'ArrowAngle', 45,...
                    'ArrowColor, 'r')
will draw the line with the specified optional parameters in the current plot.

You can get the 3D version of this here.

Required Products Image Processing Toolbox
MATLAB release MATLAB 8.0 (R2012b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
13 Aug 2013 J

J (view profile)

Nice idea but it totally screws up one of my plots, I couldn't debug your code to figure out the problem. Your code needs some serious debugging in that regard, but otherwise it draws arrows in a pretty manner. To begin: your code doesn't maintain the original axis for some reason.

25 Sep 2012 1.1

Line without arrows also included. some bugs has been fixed.

Contact us