I want to somehow label vertical lines in Matlab. I could imagine two options: Either by having legend entries right next to each vertical line itself, or by having the vertical lines numbered in the graph and then having the numbers re-appear in the legend. Is either of this possible?
I do not want to use different colors or graph patterns because I have several vertical lines and the graph is otherwise hard to read.
x is a vector of date numbers and y is price data. Date1 and Date2 are dates that are element of x.
plot(x,y), grid on;
dateaxis('x',17);
line([Date1 Date1], ylim); % I would like to have a legend entry for this right at the line in the graph
line([Date2 Date2], ylim); % I would like to have a legend entry for this right at the line in the graph
legend('Price');