Hi all,
This is my first post here so I hope I’m doing this right. I’m having problems adding a vertical line to a line plot, using either twoway or tsline, I always get the same error. First some context:
- I have a variable date, with the format %tcDD/NN/CCYY (e.g. 24/03/2021). I have observations for a year.
- I want to plot a variable that represents heart rate variability (format %10.0g, e.g. the value “109”)
- I want to add a vertical line to represent an event occurring at a given date. I know these dates beforehand, so I simply want to be able to add a line for date on the graph, for example, on the 16th of October, 2021.
This is what I do:
(this works and produces this graph)

Then I try adding the line, using
And I get the error:
invalid line argument, 16/10/2021
r(198);
The same if I use the variation:
Alternatively, I tsset date and do:
And I get the error:
invalid number, (16/10/2021)
r(198);
I hope I’m giving enough information, otherwise, apologies, and please let me know how I can make myself clearer. I’m sure this is a small technical thing I’m failing to see. I have read help, the manual, and other bits and pieces but I'm really stuck with this. Any help is highly appreciated!
Thanks.
Sergio
This is my first post here so I hope I’m doing this right. I’m having problems adding a vertical line to a line plot, using either twoway or tsline, I always get the same error. First some context:
- I have a variable date, with the format %tcDD/NN/CCYY (e.g. 24/03/2021). I have observations for a year.
- I want to plot a variable that represents heart rate variability (format %10.0g, e.g. the value “109”)
- I want to add a vertical line to represent an event occurring at a given date. I know these dates beforehand, so I simply want to be able to add a line for date on the graph, for example, on the 16th of October, 2021.
This is what I do:
Code:
twoway (line heart_rate_variability date)
Then I try adding the line, using
Code:
twoway (line heart_rate_variability date), xline(16/10/2021)
invalid line argument, 16/10/2021
r(198);
The same if I use the variation:
Code:
twoway (line heart_rate_variability date), xline(tc(16/10/2021))
Code:
tsline heart_rate_variability, tline(16/10/2021)
invalid number, (16/10/2021)
r(198);
I hope I’m giving enough information, otherwise, apologies, and please let me know how I can make myself clearer. I’m sure this is a small technical thing I’m failing to see. I have read help, the manual, and other bits and pieces but I'm really stuck with this. Any help is highly appreciated!
Thanks.
Sergio
Comment