Announcement

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

  • Coloring area in tsline graph

    Hi, I got this need looking graph I made with
    Code:
    tsline
    here:

    Click image for larger version

Name:	time_series.png
Views:	1
Size:	53.9 KB
ID:	1391929

    It shows the number of insolvencies in Germany over time (plus a 3 month moving average). I want to color in the time span between August 9th 2007 and December 31st 2010. I tried everything I could with
    Code:
    xline()
    - but I am looking for a constant shading...any ideas?

    This is basically my starting point:

    Code:
    tsline insolvencies, xline(`date("08/09/2007")) xline (`date("12/31/2012"))
    Thank you! /R

  • #2
    Discussed in detail at http://www.stata-journal.com/article...article=gr0067

    That article is behind a paywall. It's worth every dollar you might pay for it, but for the impecunious here is one method, not necessarily the best, but quite easy to understand and implement:

    Code:
    webuse grunfeld, clear 
    tsline mvalue if company == 1
    gen upper = 6240
    twoway bar upper year if inrange(year, 1939, 1945), bcolor(gs12) || tsline mvalue if company == 1 , legend(off) ytitle(mvalue)
    Incidentally the method of http://www.stata-journal.com/sjpdf.h...iclenum=gr0030 might improve your time axis labels.

    Comment


    • #3
      Wow, that was quick! Fortunately, my university has access to the Stata Journal - I will give it a read! Thank you!

      Comment

      Working...
      X