I'm trying to plot some annotations to go along with my step function graphs. I currently have these graphs, and I've been trying to figure out how to draw horizontal arrows that point towards vertical lines. I will also need labeled, vertical lines that are pointing towards horizontal lines.
I have attached an image that shows (in red) what I mean. I've tried the annotation() function, but it's truly a pain to get the arrows where I want them to be. If anyone wouldn't mind explaining how to use that function, or alternative methods for what I'm trying to achieve, that would be amazing!
EDIT: Is there a way to edit the Quiver arrowhead size?
Not quite sure if this is any better or simpler but I used the quiver()
function to plot the lines shown below. The quiver()
function takes in a few inputs in this case. In the full script below I used twice the amount of quiver()
calls to plot overlapping arrows to create a double headed arrow.
quiver(Start_Point(1),Start_Point(2),X_Displacement,Y_Displacement,0);
• Start_Point
→ equal to [x y]
(x-coordinate y-coordinate)
• Start_Point(1)
→ The x-coordinate of the arrow's start
• Start_Point(2)
→ The y-coordinate of the arrow's start
• X_Displacement
→ The horizontal distance from the start of the array
• Y_Displacement
→ The vertical distance from the start of the array
The maximum size of the arrow head can be set by using the 'MaxHeadSize'
property.
clf;
Start_Point(1) = 0;
Start_Point(2) = 0;
X_Displacement = 0; Y_Displacement = 10;
Magnitude = sqrt(X_Displacement.^2 + Y_Displacement.^2);
quiver(Start_Point(1),Start_Point(2),X_Displacement,Y_Displacement,0,'Color','r','MaxHeadSize',1/Magnitude);
hold on
Start_Point(1) = 0;
Start_Point(2) = 0;
X_Displacement = 100; Y_Displacement = 0;
Magnitude = sqrt(X_Displacement.^2 + Y_Displacement.^2);
quiver(Start_Point(1),Start_Point(2),X_Displacement,Y_Displacement,0,'Color','r','MaxHeadSize',1/Magnitude);