plotAddArrow

Purpose

Adds an arrow to an existing graph.

Format

plotAddArrow([myAnnotation, ]x_start, y_start, x_end, y_end, head_size)
Parameters:
  • myAnnotation (struct) – Optional argument. An instance of a plotAnnotation structure.
  • x_start (scalar or Nx1 vector) – the X coordinate for the start of each respective arrow.
  • y_start (scalar or Nx1 vector) – the Y coordinate for the start of each respective arrow.
  • x_end (scalar or Nx1 vector) – the X coordinate for the end of each respective arrow.
  • y_end (scalar or Nx1 vector) – the Y coordinate for the end of each respective arrow.
  • head_size (2x1 vector) – the size of the arrowhead(s) in pixels. The first element of head_size is the size for head at the end of the arrow. The second element is the size of the head at the start of the arrow.

Examples

Basic usage

x_start = 0.2;
y_start = 0.25;
x_end = 0.4;
y_end = 0.5;

// Set arrowhead at the end to 15 px
// No arrowhead at the beginning of the arrow
head_size = { 15, 0 };

// Add an arrow to graph
plotAddArrow(x_start, y_start, x_end, y_end, head_size);

Add an arrow between points

// Draw random scatter plot
x = rndu(10, 1);
y = rndu(10, 1);
plotScatter(x, y);

// Add arrow from the first point to the ninth point
plotAddArrow(x[1], y[1], x[9], y[9], 12);

Remarks

Please note that plotAddArrow() will add arrows to existing graphs, it will not create a new graph if one does not exist. plotAddArrow() is not yet supported for surface plots.