Announcement

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

  • Graphs with xtline command: Adding vertical lines and shading the area on certain sides of the vertical lines

    Hi, I would greatly appreciate it if someone could help me with the following issue.

    I have a country year cross sectional data(country=16, year=14).
    In order to show the annual change of certain variables by country, I have created line graphs with xtline command.

    Code:
    xtline x1 x2 x3, t(year) i(country)
    Manually I have added vertical lines to express the year in which certain policy was implemented/halted in certain countries.
    (I did this manually since I didn't know the code to add vertical lines when the location(year) of the vertical lines differ by country)

    Now, what I really want to do is shade the area on the right or left side of the vertical line to show when the policies are in effect and when they are not.
    Are there any ways of doing this?

    Best,
    Tate

  • #2
    There was a thread recently on adding a vertical reference line in an xtline graph (see link below).


    http://www.statalist.org/forums/foru...-twoway-graphs

    If you do not want the dot on top of the line, you can change the last line in the code to

    Code:
     xtline time_var, addplot( rarea max event_day event_day )

    In principle, you may draw a second graph of the desired shaded region and add it to the xtline graph. The problem that I foresee is the inability to change the order the graphs are drawn (unlike graph two way), and therefore the shaded region would obscure part of the xtline graph. Perhaps if you posted some sample data (using dataex), some of the graph experts in the forum may suggest alternatives.
    Last edited by Andrew Musau; 11 Jul 2016, 13:10.

    Comment

    Working...
    X