Announcement

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

  • line graph with year marks on line

    Dear Forum,

    I have time-series data and I want to plot two variables 'against' each other, so that the line displays the cyclical behaviour of the two variables over time.

    The variables are:

    hpr=real house prices
    real thh (rthh) = real household debt

    The graph below displays the relationship between hpr and rthh over time. What I would like to do, is to set time-markers on the line, at certain points (2008 f.e.)

    The code for the graph looks like this (my data-set is technically panel data):
    Code:
    line hpr rthh if iso=="USA", title("USA")



    Again, I would now like to 'mark' certain points on this line with the corresponding year. This also means, I do not want to mark each year of the time series, as this would be messy, but only certain years (1970, 1980, 1990, 2008).


    Thank you very much,
    Christian

  • #2
    You don't give a data example and your graph doesn't show properly. But this is code which anyone can run in Stata (unless behind some firewall) which shows some technique:


    Code:
    webuse grunfeld
    line invest year if company == 1 || scatter invest year if company == 1 & year == 1945, ms(none) mla(year) mlabpos(6) legend(off)
    For how to show data and graphs, see https://www.statalist.org/forums/help#stata

    Comment


    • #3
      many thanks. This appears to me like a very nice code to play around with.

      I attach some of my data, in case future statlists are interested.

      Code:
      iso    year    hpr    rthh
      
      USA    1990    100    2083.516
      USA    1991    98.32584    1961.423
      USA    1992    98.61143    1915.052
      USA    1993    98.42268    1974.233
      USA    1994    98.87716    2077.098
      USA    1995    99.49358    2137.739
      USA    1996    100.2796    2198.806
      USA    1997    101.4674    2261.668
      USA    1998    105.2039    2349.904
      USA    1999    108.1242    2409.025
      USA    2000    111.2624    2499.084
      USA    2001    116.3084    2641.415
      USA    2002    121.7087    2873.812
      USA    2003    126.3586    3107.83
      USA    2004    134.5479    3424.571
      USA    2005    144.8445    3588.566
      USA    2006    150.4489    3683.152
      USA    2007    148.0101    3691.111
      USA    2008    135.819    3633.101
      USA    2009    129.0377    3566.4
      USA    2010    121.9839    3719.516
      USA    2011    114.021    3665.457
      USA    2012    111.6191    3620.399
      USA    2013    118.1601    3610.316
      USA    2014    122.611    3662.516
      USA    2015    129.3258    3868.314
      USA    2016    134.9373    4049.373

      Comment

      Working...
      X