Clear Filters
Clear Filters

Text in plot that has x-axis in terms of datetime

11 views (last 30 days)
Hello,
I have a plot that uses a datetime structure as an x axis and I want to add a text string on my plot. Typically I would do that using text(x,y,'text'). In this case I am not sure what I would use as 'x'. The 'annotation' command uses normalized values that do not move when I zoom or pan the plot. Would appreciate some input on what I would use as my 'x' in the text function. Thanks!

Accepted Answer

Ricardo
Ricardo on 21 Jun 2016
I just had this problem and I could position the text using datenum in this way:
text(datenum( the_date ), y_axis_val, text)

More Answers (1)

dpb
dpb on 2 Sep 2015
A date number of the time x. Same idea as with ordinary axes; the date axes is one with the limits based on the first/last date of the x vector. You can retrieve these from the plot as
xlohi=xlim;
then scale between those two at whatever point you wish would be one way...
  2 Comments
dpb
dpb on 2 Sep 2015
If (as I presume given the comment) this solved the problem, please "ACCEPT" the answer -- besides my ego, it notifies other users who find the question the answer was considered/is a good 'un, thereby (hopefully) helping fulfill the idea of the forum in being a database repository...

Sign in to comment.

Categories

Find more on Data Distribution Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!