MATLAB: How to include arrows as pointers of a particular point in plot

annotationsplot

I have a graph for 3 variables as shown here. I know the saturation point co-ordinates and want arrows of the same color to be pointing them exactly like I have hand drawn in the figure. I tried annotations(arrow) function but it did not work even though I used correct co-ordinates it makes the arrow out of the boundary or maybe I was using it in a wrong way. Please help me if I can draw the arrows at a particular point I need. I would also have to declare 3 set of (x,y) co-odrinates since my main function needs to work simultanously for the three variables.
Code I tried:
plot(T,ih,T,iv,T,sh)
legend('Infected Human','Infected Mosquito','Susceptible Human','Location','east')
xlabel('Time (days)')
ylabel('Population')
x=[39636/40000 39636/40000];
y=[1 180/200];
annotation('arrow',x,y)
Thank you very much in advance.

Best Answer

annotation() takes position in figure() coordinates. The position has no relation with the x-values and y-values of your axes. If you want to specify the position of your arrows in the axes() coordinates, then you need to do a transformation. The following code shows an example. The arrow_x and arrow_y specify the position of arrows according to the x-axis and y-axis of the axes() and then use interp1 to do the transformation
fig = figure('Units', 'normalized');
ax = axes();
plot(1:10, 0.1:0.1:1);
pos = ax.Position;
pos(3:4) = pos(3:4) + pos(1:2);
arrow_x = [5 5];
arrow_y = [0.7 0.5];
arrow_x_fig = interp1(ax.XLim, pos([1 3]), arrow_x);
arrow_y_fig = interp1(ax.YLim, pos([2 4]), arrow_y);
annotation('arrow', arrow_x_fig, arrow_y_fig);