File Exchange

## circular_arrow

version 1.0.0.0 (2.67 KB) by
This is a function designed to draw a circular arrow onto the current figure.

Updated 24 Oct 2016

This function will draw a circular arrow onto the figure supplied by the figure handler. The radius, angle, orientation angle, colour and arrow head type can all be specified. There is also included functionality to be able to use a double headed arrow.

### Cite As

Zac Giles (2020). circular_arrow (https://www.mathworks.com/matlabcentral/fileexchange/59917-circular_arrow), MATLAB Central File Exchange. Retrieved .

Valdelírio Silva

Matthew Cooper

Seems to break when using a datetick axis. I tried a variety of methods to convert the position{i} coordinates to normalized units. I can get the x/y coordinates to work but the dx/dy (3rd and 4th values in position{i}, control the slope of the arrow) are not working:
ax = gca;
axpos = get(ax, 'Position');
xlims = get(gca,'XLim');
ylims = get(gca,'YLim');
difX = xlims(2) - xlims(1);
difY = ylims(2) - ylims(1);

ipos = position{i};
pos1 = ipos(1);
pos2 = ipos(2);
pos3 = ipos(3);
pos4 = ipos(4);

% these are x,y coordinates in terms of the actual data
x_start = ipos(1);
y_start = ipos(2);

% these are normalized to the axis limits
x_start = (x_start - xlims(1))/difX;
y_start = (y_start - ylims(1))/difY;

% this says axpos_xstart + x_start * axpos_xlength
newx_start = axpos(1)+x_start*axpos(3);
newy_start = axpos(2)+y_start*axpos(4);
% I thought these would work but no
newdx = pos3/axpos(3);
newdy = pos4/axpos(4);

h = annotation('arrow','Position',[newx_start newy_start newdx newdy]);

Leo Simon

Nice function. It would be great if you could improve the documentation, as others have suggested, but in other ways also. The word "arrow angle" is very misleading to me. By trial and error I figured out that if I set arrow angle = 90, the tip and tail of the arrow would have the same vertical coordinate, setting it to 0 then the tip and tail have the same horizontal coordinate. Giving these obvious examples would be great.

Christian Iandiorio

Zac Giles

Hi Nathaniel. As Nshine pointed out, that line of comment in the help is incorrect. It should read " Use 1 to get a clockwise arrow -1 to get a counter clockwise arrow, 2 to get a double headed arrow and 0 to get just an arc. " I hope this solves your problem.

Nathaniel Werner

Why does the arrow not appear when you make ccw arrows?

Elizabeth Tan

Great function! An extra feature could be an option to specify the angle of the arrowhead.

Nshine

Great function. Thanks for sharing.

The example and function have a minor 'bug' due to the comments in the example. The directions settings in the example are 0=counterclockwise arrow, 1 = clockwise arrow. However the function has 0=no arrow, 1 = clockwise arrow, 2 = both arrows. Its an easy fix though.

Chris Hooper

Great thanks! Extend to 3D?

##### MATLAB Release Compatibility
Created with R2015a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux