Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • twoway graph: adding vertical lines

    Hello
    I've got troubles with adding vertical lines in my twoway time series graph .
    On my y-axis there is the average TV-audience of 184 Champions League games and on the x-axis there is my time variable in terms of a clock time for example 21:30. The format of my time variable is %tcHH:MM and it's a double.

    When i type in my code as follows (because there are multiple overlaid line graphs)

    twoway (tsline avgrating_90 if group==1 & tin(20:45:00,22:33:00)) || (tsline avgrating_90 if group==2 & tin(20:45:00, 22:30:00)) || (tsline avgrating_90 if group==3 & tin(20:45:00, 22:30:00)) || (tsline avgrating_90 if group==4 & tin(20:45:00, 22:30:00)), tline( 21:30 21:45)

    (because my aim are two vertical lines, one at 21:30 and one at 21:45 )

    It results an error called: "invalid line argument, 21:30 21:45"
    It must be a problem with my clock time but I can't find out what it is because if I format my graph via graph editor and then want to add reference lines at a specific point in time I can't type in a double dot.
    Click image for larger version

Name:	graph1.png
Views:	3
Size:	15.2 KB
ID:	1364116




    Help would be greatly appreciated
    Kind regards
    Elias

    ps: There is suddenly a vertical line but in my stata graph there isn't one (probably because I transformed my stata graph into a PNG-file for attaching it here).
    Last edited by Elias Ritter; 13 Nov 2016, 10:07.

  • #2
    Repeat of http://www.statalist.org/forums/foru...-line-on-graph -- or so it seems. See advice on bumping etc. at http://www.statalist.org/forums/help#adviceextras #1

    One reason you may have had no answers is the lack of a data example to make this reproducible.

    Comment


    • #3
      Thanks for your advice Mr. Cox and I apologize for repeating the same question again.

      A data example would be:

      list id t_hm avgrating_90 group in 1/15

      +--------------------------------------------+
      | id t_hm avgrat_90 group |
      |--------------------------------------------|
      1. | 24 20:45 162.22505 4 |
      2. | 24 20:46 171.9264 4 |
      3. | 24 20:47 181.48797 4 |
      4. | 24 20:48 192.54053 4 |
      5. | 24 20:49 203.77003 4 |
      |--------------------------------------------|
      6. | 24 20:50 216.61693 4 |
      7. | 24 20:51 227.21005 4 |
      8. | 24 20:52 235.27159 4 |
      9. | 24 20:53 241.78465 4 |
      10.| 24 20:54 246.53194 4 |
      |--------------------------------------------|
      11. | 24 20:55 246.62209 4 |
      12. | 24 20:56 248.02312 4 |
      13. | 24 20:57 248.94183 4 |
      14. | 24 20:58 252.89003 4 |
      15. | 24 20:59 257.48803 4 |
      +----------------------------------------------+

      It's a panel dataset.

      Is this what you have meant Mr. Cox?

      Comment


      • #4
        Please use code tags (#) to post your data.
        You can add vertical lines to your graph by using xline options for twoway graph (help added_line_options). Here is an example of using this option with SIF values (help datetime):

        Code:
        twoway (tsline avgrating_90 if group==1 & tin(20:45, 22:30))  ///
        (tsline avgrating_90 if group==2 & tin(20:45, 22:30))  ///
        (tsline avgrating_90 if group==3 & tin(20:45, 22:30))   ///
        (tsline avgrating_90 if group==4 & tin(20:45, 22:30)),  ///
        xline(`=clock("21:30","hm")' `=clock("21:45","hm")')

        Comment


        • #5
          Thanks a lot for your advice Mr. Mcdossi

          Your code has produced exactly what I've wanted.

          Comment

          Working...
          X